Skip to content

Behavior difference: Callback-first promise resolve() gives inconsistent error #3641

@hkleungai

Description

@hkleungai

Steps to reproduce

  1. Start a plain new project
    • "@typescript/native-preview": "7.0.0-dev.20260428.1",
    • "typescript": "6.0.3"
  2. Run npx tsgo --init to get the default tsconfig. Turn on these flags as well.
    • "allowJs": true,
    • "checkJs": true,
    • "stableTypeOrdering": true,
  3. Add src/main.js. Run npx tsc --noEmit & npx tsgo --noEmit to see the difference.
// src/main.js
new Promise((resolve) => resolve());

Behavior with typescript@6.0

src/main.js:2:26 - error TS2810: Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments.

2 new Promise((resolve) => resolve());
                           ~~~~~~~


Found 1 error in src/main.js:2

Behavior with tsgo

src/main.js:2:26 - error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?

2 new Promise((resolve) => resolve());
                           ~~~~~~~

  node_modules/.../lib.es2015.promise.d.ts:29:34 - An argument for 'value' was not provided.
    29     new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in src/main.js:2

I think TS 6 makes more sense in this case, since type argument is not really a thing inside a javascript file.

Metadata

Metadata

Assignees

Labels

Domain: Type CheckingRelated to type checking, grammar checkingbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions