diff --git a/src/lib/es2018.asyncgenerator.d.ts b/src/lib/es2018.asyncgenerator.d.ts index 76275c92575c0..7080d427d41b8 100644 --- a/src/lib/es2018.asyncgenerator.d.ts +++ b/src/lib/es2018.asyncgenerator.d.ts @@ -2,9 +2,9 @@ interface AsyncGenerator extends AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; - return(value: TReturn | PromiseLike): Promise>; - throw(e: any): Promise>; + next(...args: [] | [TNext]): Promise ? UReturn : TReturn>>; + return(value: TReturn): Promise ? UReturn : TReturn>>; + throw(e: any): Promise ? UReturn : TReturn>>; [Symbol.asyncIterator](): AsyncGenerator; } diff --git a/src/lib/es2018.asynciterable.d.ts b/src/lib/es2018.asynciterable.d.ts index d5d83f31893bb..8465b30fbea84 100644 --- a/src/lib/es2018.asynciterable.d.ts +++ b/src/lib/es2018.asynciterable.d.ts @@ -11,9 +11,9 @@ interface SymbolConstructor { interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; - return?(value?: TReturn | PromiseLike): Promise>; - throw?(e?: any): Promise>; + next(...args: [] | [TNext]): Promise ? UReturn : TReturn>>; + return?(value?: TReturn): Promise ? UReturn : TReturn>>; + throw?(e?: any): Promise ? UReturn : TReturn>>; } interface AsyncIterable { @@ -22,4 +22,4 @@ interface AsyncIterable { interface AsyncIterableIterator extends AsyncIterator { [Symbol.asyncIterator](): AsyncIterableIterator; -} \ No newline at end of file +} diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt index d7ec011bcedc1..9f22060b9e936 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. Type 'IteratorResult' is not assignable to type 'IteratorResult'. Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. @@ -14,7 +14,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(16,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. @@ -22,7 +22,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. @@ -32,7 +32,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. @@ -53,7 +53,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(67,42): error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncGenerator' but required in type 'Iterable'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(70,42): error TS2322: Type 'AsyncGenerator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. + Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. Type 'Promise>' is not assignable to type 'IteratorResult'. Property 'value' is missing in type 'Promise>' but required in type 'IteratorYieldResult'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(74,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. @@ -79,7 +79,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. !!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. !!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. @@ -98,7 +98,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield* (async function * () { yield "a"; })(); }; @@ -110,7 +110,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield "a"; }; @@ -128,7 +128,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield* (async function * () { yield "a"; })(); }; @@ -211,7 +211,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. +!!! error TS2322: Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. !!! error TS2322: Type 'Promise>' is not assignable to type 'IteratorResult'. !!! error TS2322: Property 'value' is missing in type 'Promise>' but required in type 'IteratorYieldResult'. !!! related TS2728 /.ts/lib.es2015.iterable.d.ts:33:5: 'value' is declared here.