forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better typings for Promise executor, like microsoft#31117
- Loading branch information
Showing
20 changed files
with
311 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 26 additions & 1 deletion
27
tests/baselines/reference/asyncArrowFunction10_es5.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 26 additions & 1 deletion
27
tests/baselines/reference/asyncArrowFunction6_es5.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts(1,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts(1,27): error TS1109: Expression expected. | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts(1,30): error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
Type 'Promise<T | (T extends PromiseLike<infer U> ? U : T)>' is not assignable to type 'PromiseLike<T>'. | ||
Types of property 'then' are incompatible. | ||
Type '<TResult1 = T | (T extends PromiseLike<infer U> ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike<infer U> ? U : T)) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'. | ||
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. | ||
Types of parameters 'value' and 'value' are incompatible. | ||
Type 'T | (T extends PromiseLike<infer U> ? U : T)' is not assignable to type 'T'. | ||
'T | (T extends PromiseLike<infer U> ? U : T)' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
Type 'T extends PromiseLike<infer U> ? U : T' is not assignable to type 'T'. | ||
'T extends PromiseLike<infer U> ? U : T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
Type 'unknown' is not assignable to type 'T'. | ||
'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
|
||
|
||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts (2 errors) ==== | ||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts (3 errors) ==== | ||
var foo = async (a = await): Promise<void> => { | ||
~~~~~ | ||
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. | ||
~ | ||
!!! error TS1109: Expression expected. | ||
~~~~~~~~~~~~~ | ||
!!! error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
!!! error TS1055: Type 'Promise<T | (T extends PromiseLike<infer U> ? U : T)>' is not assignable to type 'PromiseLike<T>'. | ||
!!! error TS1055: Types of property 'then' are incompatible. | ||
!!! error TS1055: Type '<TResult1 = T | (T extends PromiseLike<infer U> ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike<infer U> ? U : T)) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'. | ||
!!! error TS1055: Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. | ||
!!! error TS1055: Types of parameters 'value' and 'value' are incompatible. | ||
!!! error TS1055: Type 'T | (T extends PromiseLike<infer U> ? U : T)' is not assignable to type 'T'. | ||
!!! error TS1055: 'T | (T extends PromiseLike<infer U> ? U : T)' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
!!! error TS1055: Type 'T extends PromiseLike<infer U> ? U : T' is not assignable to type 'T'. | ||
!!! error TS1055: 'T extends PromiseLike<infer U> ? U : T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
!!! error TS1055: Type 'unknown' is not assignable to type 'T'. | ||
!!! error TS1055: 'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
} |
30 changes: 29 additions & 1 deletion
30
tests/baselines/reference/asyncArrowFunction7_es5.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(1,21): error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
Type 'Promise<T | (T extends PromiseLike<infer U> ? U : T)>' is not assignable to type 'PromiseLike<T>'. | ||
Types of property 'then' are incompatible. | ||
Type '<TResult1 = T | (T extends PromiseLike<infer U> ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike<infer U> ? U : T)) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'. | ||
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. | ||
Types of parameters 'value' and 'value' are incompatible. | ||
Type 'T | (T extends PromiseLike<infer U> ? U : T)' is not assignable to type 'T'. | ||
'T | (T extends PromiseLike<infer U> ? U : T)' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
Type 'T extends PromiseLike<infer U> ? U : T' is not assignable to type 'T'. | ||
'T extends PromiseLike<infer U> ? U : T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
Type 'unknown' is not assignable to type 'T'. | ||
'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(3,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(3,29): error TS1109: Expression expected. | ||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(3,32): error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
|
||
|
||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts (2 errors) ==== | ||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts (4 errors) ==== | ||
var bar = async (): Promise<void> => { | ||
~~~~~~~~~~~~~ | ||
!!! error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
!!! error TS1055: Type 'Promise<T | (T extends PromiseLike<infer U> ? U : T)>' is not assignable to type 'PromiseLike<T>'. | ||
!!! error TS1055: Types of property 'then' are incompatible. | ||
!!! error TS1055: Type '<TResult1 = T | (T extends PromiseLike<infer U> ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike<infer U> ? U : T)) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'. | ||
!!! error TS1055: Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. | ||
!!! error TS1055: Types of parameters 'value' and 'value' are incompatible. | ||
!!! error TS1055: Type 'T | (T extends PromiseLike<infer U> ? U : T)' is not assignable to type 'T'. | ||
!!! error TS1055: 'T | (T extends PromiseLike<infer U> ? U : T)' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
!!! error TS1055: Type 'T extends PromiseLike<infer U> ? U : T' is not assignable to type 'T'. | ||
!!! error TS1055: 'T extends PromiseLike<infer U> ? U : T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
!!! error TS1055: Type 'unknown' is not assignable to type 'T'. | ||
!!! error TS1055: 'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. | ||
// 'await' here is an identifier, and not an await expression. | ||
var foo = async (a = await): Promise<void> => { | ||
~~~~~ | ||
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. | ||
~ | ||
!!! error TS1109: Expression expected. | ||
~~~~~~~~~~~~~ | ||
!!! error TS1055: Type 'PromiseConstructor' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. | ||
} | ||
} |
27 changes: 26 additions & 1 deletion
27
tests/baselines/reference/asyncArrowFunction8_es5.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.