From 3476da2f47232a185891cd614d9f429e9f59e215 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 23 Aug 2019 15:02:06 -0700 Subject: [PATCH] Better typings for Promise executor, like #31117 --- src/lib/es2015.promise.d.ts | 2 +- .../asyncArrowFunction10_es5.errors.txt | 27 ++++++++++- .../asyncArrowFunction6_es5.errors.txt | 27 ++++++++++- .../asyncArrowFunction7_es5.errors.txt | 30 ++++++++++++- .../asyncArrowFunction8_es5.errors.txt | 27 ++++++++++- .../asyncAwaitIsolatedModules_es5.errors.txt | 45 ++++++++++++++++++- .../asyncAwaitNestedClasses_es5.types | 6 +-- .../reference/asyncDeclare_es5.errors.txt | 29 +++++++++++- .../asyncFunctionDeclaration13_es5.errors.txt | 27 ++++++++++- .../asyncFunctionDeclaration6_es5.errors.txt | 27 ++++++++++- .../asyncFunctionDeclaration7_es5.errors.txt | 30 ++++++++++++- .../asyncFunctionDeclaration9_es5.errors.txt | 27 ++++++++++- .../reference/asyncImportedPromise_es5.types | 2 +- .../reference/asyncImportedPromise_es6.types | 2 +- .../asyncQualifiedReturnType_es5.types | 2 +- .../asyncQualifiedReturnType_es6.types | 2 +- ...xtuallyTypeAsyncFunctionAwaitOperand.types | 6 +-- ...textuallyTypeAsyncFunctionReturnType.types | 12 ++--- .../baselines/reference/inferenceLimit.types | 6 +-- .../initial-build/resolves-correctly.js | 12 ++--- 20 files changed, 311 insertions(+), 37 deletions(-) diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index 83776137c33c1..72ebe87ba07d8 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -10,7 +10,7 @@ interface PromiseConstructor { * a resolve callback used to 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 (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + new (executor: (resolve: (value?: T) => void, reject: (reason?: any) => void) => void): Promise ? U : T>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises diff --git a/tests/baselines/reference/asyncArrowFunction10_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es5.errors.txt index 5b4505ebfde2e..e8b5e78cb3c1c 100644 --- a/tests/baselines/reference/asyncArrowFunction10_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction10_es5.errors.txt @@ -1,8 +1,33 @@ +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/asyncArrowFunction10_es5.ts(3,11): error TS2304: Cannot find name 'await'. -==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts (2 errors) ==== var foo = async (): Promise => { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. // Legal to use 'await' in a type context. var v: await; ~~~~~ diff --git a/tests/baselines/reference/asyncArrowFunction6_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es5.errors.txt index 9d0dbd748807a..87bc3690e6d7e 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction6_es5.errors.txt @@ -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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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 => { ~~~~~ !!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es5.errors.txt index 5d4f03cbc41b8..7113901f5c102 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction7_es5.errors.txt @@ -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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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 => { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 => { ~~~~~ !!! 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. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es5.errors.txt index 620d0b5653b7c..ea00b222c7582 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction8_es5.errors.txt @@ -1,8 +1,33 @@ +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/asyncArrowFunction8_es5.ts(2,19): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts (2 errors) ==== var foo = async (): Promise => { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. var v = { [await]: foo } ~ !!! error TS1109: Expression expected. diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.errors.txt index 7d46517ca159f..20c7d0ad15aeb 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.errors.txt +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.errors.txt @@ -1,7 +1,25 @@ tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts(1,27): error TS2307: Cannot find module 'missing'. +tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts(7,22): 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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/asyncAwaitIsolatedModules_es5.ts(11,28): 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/asyncAwaitIsolatedModules_es5.ts(15,20): 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/asyncAwaitIsolatedModules_es5.ts(19,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. +tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts(24,14): 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/asyncAwaitIsolatedModules_es5.ts(30,14): 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/asyncAwaitIsolatedModules_es5.ts(33,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. -==== tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts (8 errors) ==== import { MyPromise } from "missing"; ~~~~~~~~~ !!! error TS2307: Cannot find module 'missing'. @@ -11,32 +29,57 @@ tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts(1,27): error async function f0() { } async function f1(): Promise { } + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. async function f3(): MyPromise { } let f4 = async function() { } let f5 = async function(): Promise { } + ~~~~~~~~~~~~~ +!!! 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. let f6 = async function(): MyPromise { } let f7 = async () => { }; let f8 = async (): Promise => { }; + ~~~~~~~~~~~~~ +!!! 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. let f9 = async (): MyPromise => { }; let f10 = async () => p; let f11 = async () => mp; let f12 = async (): Promise => mp; + ~~~~~~~~~~~~~~~ +!!! 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. let f13 = async (): MyPromise => p; let o = { async m1() { }, async m2(): Promise { }, + ~~~~~~~~~~~~~ +!!! 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. async m3(): MyPromise { } }; class C { async m1() { } async m2(): Promise { } + ~~~~~~~~~~~~~ +!!! 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. async m3(): MyPromise { } static async m4() { } static async m5(): Promise { } + ~~~~~~~~~~~~~ +!!! 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. static async m6(): MyPromise { } } diff --git a/tests/baselines/reference/asyncAwaitNestedClasses_es5.types b/tests/baselines/reference/asyncAwaitNestedClasses_es5.types index 40f0e5ce9b900..ceba067940be1 100644 --- a/tests/baselines/reference/asyncAwaitNestedClasses_es5.types +++ b/tests/baselines/reference/asyncAwaitNestedClasses_es5.types @@ -14,10 +14,10 @@ class A { return new Promise((resolve) => { resolve(null); }); >new Promise((resolve) => { resolve(null); }) : Promise >Promise : PromiseConstructor ->(resolve) => { resolve(null); } : (resolve: (value?: void | PromiseLike) => void) => void ->resolve : (value?: void | PromiseLike) => void +>(resolve) => { resolve(null); } : (resolve: (value?: void) => void) => void +>resolve : (value?: void) => void >resolve(null) : void ->resolve : (value?: void | PromiseLike) => void +>resolve : (value?: void) => void >null : null } static C = class C { diff --git a/tests/baselines/reference/asyncDeclare_es5.errors.txt b/tests/baselines/reference/asyncDeclare_es5.errors.txt index bfa467acca219..55d2aad950716 100644 --- a/tests/baselines/reference/asyncDeclare_es5.errors.txt +++ b/tests/baselines/reference/asyncDeclare_es5.errors.txt @@ -1,7 +1,32 @@ tests/cases/conformance/async/es5/asyncDeclare_es5.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. +tests/cases/conformance/async/es5/asyncDeclare_es5.ts(1,31): 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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/asyncDeclare_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/asyncDeclare_es5.ts (2 errors) ==== declare async function foo(): Promise; ~~~~~ -!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file +!!! error TS1040: 'async' modifier cannot be used in an ambient context. + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es5.errors.txt index ce83aabc4bed8..bb56490c2e64a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration13_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es5.errors.txt @@ -1,8 +1,33 @@ +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration13_es5.ts(1,23): 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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/functionDeclarations/asyncFunctionDeclaration13_es5.ts(3,11): error TS2304: Cannot find name 'await'. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration13_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration13_es5.ts (2 errors) ==== async function foo(): Promise { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. // Legal to use 'await' in a type context. var v: await; ~~~~~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es5.errors.txt index d8cf82fbc28e3..2556e617efc1b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es5.errors.txt @@ -1,11 +1,36 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts(1,29): error TS1109: Expression expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts(1,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. + Type 'Promise ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/functionDeclarations/asyncFunctionDeclaration6_es5.ts (2 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts (3 errors) ==== async function foo(a = await): Promise { ~~~~~ !!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es5.errors.txt index 48984724e4c16..672f4be43e6d9 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es5.errors.txt @@ -1,14 +1,42 @@ +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts(1,23): 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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/functionDeclarations/asyncFunctionDeclaration7_es5.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts(3,31): error TS1109: Expression expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts(3,34): 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/functionDeclarations/asyncFunctionDeclaration7_es5.ts (2 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts (4 errors) ==== async function bar(): Promise { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 a yield expression. async function foo(a = await): Promise { ~~~~~ !!! 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. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es5.errors.txt index 8eed8dade45bc..ddcc9b69791cb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es5.errors.txt @@ -1,8 +1,33 @@ +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration9_es5.ts(1,23): 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 ? U : T)>' is not assignable to type 'PromiseLike'. + Types of property 'then' are incompatible. + Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. + Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. + Types of parameters 'value' and 'value' are incompatible. + Type 'T | (T extends PromiseLike ? U : T)' is not assignable to type 'T'. + 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. + 'T extends PromiseLike ? 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/functionDeclarations/asyncFunctionDeclaration9_es5.ts(2,19): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration9_es5.ts (1 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration9_es5.ts (2 errors) ==== async function foo(): Promise { + ~~~~~~~~~~~~~ +!!! 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 ? U : T)>' is not assignable to type 'PromiseLike'. +!!! error TS1055: Types of property 'then' are incompatible. +!!! error TS1055: Type ' ? U : T), TResult2 = never>(onfulfilled?: (value: T | (T extends PromiseLike ? U : T)) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. +!!! 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 ? U : T)' is not assignable to type 'T'. +!!! error TS1055: 'T | (T extends PromiseLike ? 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 ? U : T' is not assignable to type 'T'. +!!! error TS1055: 'T extends PromiseLike ? 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 '{}'. var v = { [await]: foo } ~ !!! error TS1109: Expression expected. diff --git a/tests/baselines/reference/asyncImportedPromise_es5.types b/tests/baselines/reference/asyncImportedPromise_es5.types index c8ea6bdf61e5d..809b0370b3cf1 100644 --- a/tests/baselines/reference/asyncImportedPromise_es5.types +++ b/tests/baselines/reference/asyncImportedPromise_es5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es5/task.ts === export class Task extends Promise { } >Task : Task ->Promise : Promise +>Promise : Promise ? U : T> === tests/cases/conformance/async/es5/test.ts === import { Task } from "./task"; diff --git a/tests/baselines/reference/asyncImportedPromise_es6.types b/tests/baselines/reference/asyncImportedPromise_es6.types index 05411f1dda588..c32f669665337 100644 --- a/tests/baselines/reference/asyncImportedPromise_es6.types +++ b/tests/baselines/reference/asyncImportedPromise_es6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/task.ts === export class Task extends Promise { } >Task : Task ->Promise : Promise +>Promise : Promise ? U : T> === tests/cases/conformance/async/es6/test.ts === import { Task } from "./task"; diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es5.types b/tests/baselines/reference/asyncQualifiedReturnType_es5.types index 8df2ac42c50c9..9fcfdbba2d63a 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es5.types +++ b/tests/baselines/reference/asyncQualifiedReturnType_es5.types @@ -4,7 +4,7 @@ namespace X { export class MyPromise extends Promise { >MyPromise : MyPromise ->Promise : Promise +>Promise : Promise ? U : T> } } diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es6.types b/tests/baselines/reference/asyncQualifiedReturnType_es6.types index f1878fed5d80f..a69b7cc0476a0 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es6.types +++ b/tests/baselines/reference/asyncQualifiedReturnType_es6.types @@ -4,7 +4,7 @@ namespace X { export class MyPromise extends Promise { >MyPromise : MyPromise ->Promise : Promise +>Promise : Promise ? U : T> } } diff --git a/tests/baselines/reference/contextuallyTypeAsyncFunctionAwaitOperand.types b/tests/baselines/reference/contextuallyTypeAsyncFunctionAwaitOperand.types index 377f7c15ae321..2b8f7e79fcbca 100644 --- a/tests/baselines/reference/contextuallyTypeAsyncFunctionAwaitOperand.types +++ b/tests/baselines/reference/contextuallyTypeAsyncFunctionAwaitOperand.types @@ -17,10 +17,10 @@ async function fn1(): Promise { >await new Promise(resolve => resolve({ key: "value" })) : Obj >new Promise(resolve => resolve({ key: "value" })) : Promise >Promise : PromiseConstructor ->resolve => resolve({ key: "value" }) : (resolve: (value?: Obj | PromiseLike) => void) => void ->resolve : (value?: Obj | PromiseLike) => void +>resolve => resolve({ key: "value" }) : (resolve: (value?: Obj) => void) => void +>resolve : (value?: Obj) => void >resolve({ key: "value" }) : void ->resolve : (value?: Obj | PromiseLike) => void +>resolve : (value?: Obj) => void >{ key: "value" } : { key: "value"; } >key : "value" >"value" : "value" diff --git a/tests/baselines/reference/contextuallyTypeAsyncFunctionReturnType.types b/tests/baselines/reference/contextuallyTypeAsyncFunctionReturnType.types index d47a623ffc6c3..f9462634dcec0 100644 --- a/tests/baselines/reference/contextuallyTypeAsyncFunctionReturnType.types +++ b/tests/baselines/reference/contextuallyTypeAsyncFunctionReturnType.types @@ -17,12 +17,12 @@ async function fn2(): Promise { return new Promise(resolve => { >new Promise(resolve => { resolve({ key: "value" }); }) : Promise >Promise : PromiseConstructor ->resolve => { resolve({ key: "value" }); } : (resolve: (value?: Obj | PromiseLike) => void) => void ->resolve : (value?: Obj | PromiseLike) => void +>resolve => { resolve({ key: "value" }); } : (resolve: (value?: Obj) => void) => void +>resolve : (value?: Obj) => void resolve({ key: "value" }); >resolve({ key: "value" }) : void ->resolve : (value?: Obj | PromiseLike) => void +>resolve : (value?: Obj) => void >{ key: "value" } : { key: "value"; } >key : "value" >"value" : "value" @@ -47,12 +47,12 @@ async function fn4(): Promise { >await new Promise(resolve => { resolve({ key: "value" }); }) : Obj >new Promise(resolve => { resolve({ key: "value" }); }) : Promise >Promise : PromiseConstructor ->resolve => { resolve({ key: "value" }); } : (resolve: (value?: Obj | PromiseLike) => void) => void ->resolve : (value?: Obj | PromiseLike) => void +>resolve => { resolve({ key: "value" }); } : (resolve: (value?: Obj) => void) => void +>resolve : (value?: Obj) => void resolve({ key: "value" }); >resolve({ key: "value" }) : void ->resolve : (value?: Obj | PromiseLike) => void +>resolve : (value?: Obj) => void >{ key: "value" } : { key: "value"; } >key : "value" >"value" : "value" diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index 6aa7ab501ea16..3b6973bc9030f 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -19,8 +19,8 @@ export class BrokenClass { >new Promise>((resolve, reject) => { let result: Array = []; let populateItems = (order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); }; return Promise.all(result.map(populateItems)) .then((orders: Array) => { resolve(orders); }); }) : Promise >Promise : PromiseConstructor >MyModule : any ->(resolve, reject) => { let result: Array = []; let populateItems = (order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); }; return Promise.all(result.map(populateItems)) .then((orders: Array) => { resolve(orders); }); } : (resolve: (value?: MyModule.MyModel[] | PromiseLike) => void, reject: (reason?: any) => void) => Promise ->resolve : (value?: MyModule.MyModel[] | PromiseLike) => void +>(resolve, reject) => { let result: Array = []; let populateItems = (order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); }; return Promise.all(result.map(populateItems)) .then((orders: Array) => { resolve(orders); }); } : (resolve: (value?: MyModule.MyModel[]) => void, reject: (reason?: any) => void) => Promise +>resolve : (value?: MyModule.MyModel[]) => void >reject : (reason?: any) => void let result: Array = []; @@ -93,7 +93,7 @@ export class BrokenClass { resolve(orders); >resolve(orders) : void ->resolve : (value?: MyModule.MyModel[] | PromiseLike) => void +>resolve : (value?: MyModule.MyModel[]) => void >orders : MyModule.MyModel[] }); diff --git a/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/resolves-correctly.js b/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/resolves-correctly.js index 2ba8fa808170b..01b6d2e05b696 100644 --- a/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/resolves-correctly.js +++ b/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/resolves-correctly.js @@ -42,8 +42,8 @@ exports.__esModule = true; "signature": "232404497324" }, "../../../.ts/lib.es2015.promise.d.ts": { - "version": "235321148269", - "signature": "235321148269" + "version": "17314103363", + "signature": "17314103363" }, "../../../.ts/lib.es2015.proxy.d.ts": { "version": "55479865087", @@ -142,8 +142,8 @@ exports.__esModule = true; "signature": "232404497324" }, "../../../.ts/lib.es2015.promise.d.ts": { - "version": "235321148269", - "signature": "235321148269" + "version": "17314103363", + "signature": "17314103363" }, "../../../.ts/lib.es2015.proxy.d.ts": { "version": "55479865087", @@ -265,8 +265,8 @@ exports.getVar = getVar; "signature": "232404497324" }, "../../../.ts/lib.es2015.promise.d.ts": { - "version": "235321148269", - "signature": "235321148269" + "version": "17314103363", + "signature": "17314103363" }, "../../../.ts/lib.es2015.proxy.d.ts": { "version": "55479865087",