Skip to content

Fix Promise constructor signature #19633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/es2015.promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ interface PromiseConstructor {
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
new (executor: (resolve: (value?: void | PromiseLike<void>) => void, reject: (reason?: any) => void) => void): Promise<void>;
new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;

/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,18): error TS2304: Cannot find name 'await'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,24): error TS1005: ',' expected.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: '=' expected.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,40): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es20
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/asyncArrowFunction5_es5.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,18): error TS2304: Cannot find name 'await'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,24): error TS1005: ',' expected.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: '=' expected.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,40): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/asyncArrowFunction5_es6.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,18): error TS2304: Cannot find name 'await'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,24): error TS1005: ',' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: '=' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,40): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,18): error TS2304: Cannot find name 'a'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,37): error TS1005: ',' expected.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: '=' expected.
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,53): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es20
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/asyncArrowFunction9_es5.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,18): error TS2304: Cannot find name 'a'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,37): error TS1005: ',' expected.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: '=' expected.
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,53): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/asyncArrowFunction9_es6.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected.

Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 223:12, but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts] ////

//// [a.ts]
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
export default x;

//// [b.ts]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
>x : Symbol(x, Decl(a.ts, 0, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>reject : Symbol(reject, Decl(a.ts, 0, 33))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>resolve : Symbol(resolve, Decl(a.ts, 0, 28))
>reject : Symbol(reject, Decl(a.ts, 0, 37))
>resolve : Symbol(resolve, Decl(a.ts, 0, 28))

export default x;
>x : Symbol(x, Decl(a.ts, 0, 5))
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/defaultExportInAwaitExpression01.types
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
>x : Promise<{}>
>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>Promise : PromiseConstructor
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
>resolve( {} ) : void
>resolve : (value?: {} | PromiseLike<{}>) => void
>resolve : (value: {} | PromiseLike<{}>) => void
>{} : {}

export default x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts] ////

//// [a.ts]
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
export default x;

//// [b.ts]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
>x : Symbol(x, Decl(a.ts, 0, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>reject : Symbol(reject, Decl(a.ts, 0, 33))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>resolve : Symbol(resolve, Decl(a.ts, 0, 28))
>reject : Symbol(reject, Decl(a.ts, 0, 37))
>resolve : Symbol(resolve, Decl(a.ts, 0, 28))

export default x;
>x : Symbol(x, Decl(a.ts, 0, 5))
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/defaultExportInAwaitExpression02.types
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
const x = new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } );
>x : Promise<{}>
>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>new Promise<{}>( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>Promise : PromiseConstructor
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
>resolve( {} ) : void
>resolve : (value?: {} | PromiseLike<{}>) => void
>resolve : (value: {} | PromiseLike<{}>) => void
>{} : {}

export default x;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/inferenceLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BrokenClass {
let result: Array<MyModule.MyModel> = [];

let populateItems = (order) => {
return new Promise((resolve, reject) => {
return new Promise<{}>((resolve, reject) => {
this.doStuff(order.id)
.then((items) => {
order.items = items;
Expand Down
8 changes: 4 additions & 4 deletions tests/baselines/reference/inferenceLimit.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export class BrokenClass {
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
>order : Symbol(order, Decl(file1.ts, 12, 25))

return new Promise((resolve, reject) => {
return new Promise<{}>((resolve, reject) => {
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>resolve : Symbol(resolve, Decl(file1.ts, 13, 26))
>reject : Symbol(reject, Decl(file1.ts, 13, 34))
>resolve : Symbol(resolve, Decl(file1.ts, 13, 30))
>reject : Symbol(reject, Decl(file1.ts, 13, 38))

this.doStuff(order.id)
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
Expand All @@ -52,7 +52,7 @@ export class BrokenClass {
>items : Symbol(items, Decl(file1.ts, 15, 17))

resolve(order);
>resolve : Symbol(resolve, Decl(file1.ts, 13, 26))
>resolve : Symbol(resolve, Decl(file1.ts, 13, 30))
>order : Symbol(order, Decl(file1.ts, 12, 25))

});
Expand Down
Loading