Skip to content

Types derived from HANDLE do not work and default to any #121

Description

@altxt2

Types derived from HANDLE do not work and default to any, likely due to a missing dependency in win32-def

Steps to reproduce

  • npm init -y
  • npm install typescript @types/node win32-def
  • node_modules\.bin\tsc --init
  • create app.ts:
    import type { HANDLE } from 'win32-def/types'
    let testVar: HANDLE
    
  • edit tsconfig.json:
    "module": "nodenext", // or "preserve"
    "moduleResolution": "nodenext", // or "bundler"
    "skipLibCheck": false
    
  • open app.ts in VS Code and hover mouse over testVar
  • node_modules\.bin\tsc --noEmit

Expected outcome

  • type of testVar is HANDLE or number or similar
  • tsc produces no errors

Actual outcome

  • type of testVar is any
  • tsc produces this:
node_modules/win32-def/src/lib/common.types.ts:6:32 - error TS2307: Cannot find module '@waiting/shared-types' or its corresponding type declarations.

6 import type { BigIntStr } from '@waiting/shared-types'
                                 ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/win32-def/src/lib/ffi.types.ts:3:51 - error TS2307: Cannot find module '@waiting/shared-types' or its corresponding type declarations.

3 import type { BigIntStr, MethodTypeUnknown } from '@waiting/shared-types'
                                                    ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/win32-def/src/lib/types.ts:2:38 - error TS2307: Cannot find module '@waiting/shared-types' or its corresponding type declarations.

2 import type { ToAsyncFunction } from '@waiting/shared-types'
                                       ~~~~~~~~~~~~~~~~~~~~~~~

Found 3 errors in 3 files.

Errors  Files
     1  node_modules/win32-def/src/lib/common.types.ts:6
     1  node_modules/win32-def/src/lib/ffi.types.ts:3
     1  node_modules/win32-def/src/lib/types.ts:2

Workaround

npm install @waiting/shared-types
Note that there are further type errors in this package, so it's probably best to reset skipLibCheck to true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions