Skip to content

[@types/node] util.promisify gives wrong type when using --checkJs --allowJs #33340

@chiawendt

Description

@chiawendt

If you know how to fix the issue, make a pull request instead.

Code to reproduce:

Note: I am using --checkJs --allowJs to type checking my js project.

Link to a minimal repo that reproduce this bug

index.js

const { promisify } = require('util')

const f = promisify((a, callback) => {})
const g = promisify((a, b, callback) => {})

f(1) // error TS2554: Expected 0 arguments, but got 1.
g(1,2) // error TS2554: Expected 0 arguments, but got 2.

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "allowJs": true,
    "checkJs": true,
    "noEmit": true,
    "strict": false,
  }
}

package.json

{
  "devDependencies": {
    "@types/node": "^11.9.5",
    "typescript": "^3.3.3333"
  }
}

Error output

$ npx tsc
index.js:6:1 - error TS2554: Expected 0 arguments, but got 1.

6 f(1)
  ~~~~

index.js:7:1 - error TS2554: Expected 0 arguments, but got 2.

7 g(1,2)
  ~~~~~~


Found 2 errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions