diff --git a/tsc/internal/bundled/libs/lib.es2026.array.d.ts b/tsc/internal/bundled/libs/lib.es2026.array.d.ts index 9eb835d8a0a13..82c721c9b5d7b 100644 --- a/tsc/internal/bundled/libs/lib.es2026.array.d.ts +++ b/tsc/internal/bundled/libs/lib.es2026.array.d.ts @@ -28,5 +28,11 @@ interface ArrayConstructor { * Each return value is awaited before being added to result array. * @param thisArg Value of 'this' used when executing mapFn. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + fromAsync(iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + fromAsync(iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; + fromAsync( + iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), + mapFn: (value: TAsync | Awaited, index: number) => U, + thisArg?: any, + ): Promise[]>; } diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsync.symbols b/tsc/testdata/baselines/reference/compiler/arrayFromAsync.symbols index a0ffc02248bd1..79733ab4879de 100644 --- a/tsc/testdata/baselines/reference/compiler/arrayFromAsync.symbols +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsync.symbols @@ -81,16 +81,16 @@ for await (const v of asyncGen(4)) { const sameArr1 = await Array.fromAsync(arrLike); >sameArr1 : Symbol(sameArr1, Decl(arrayFromAsync.ts, 25, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >arrLike : Symbol(arrLike, Decl(arrayFromAsync.ts, 12, 5)) const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]); >sameArr2 : Symbol(sameArr2, Decl(arrayFromAsync.ts, 26, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) @@ -106,16 +106,16 @@ const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), const sameArr3 = await Array.fromAsync(genPromises(4)); >sameArr3 : Symbol(sameArr3, Decl(arrayFromAsync.ts, 27, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >genPromises : Symbol(genPromises, Decl(arrayFromAsync.ts, 4, 3)) const sameArr4 = await Array.fromAsync(asyncGen(4)); >sameArr4 : Symbol(sameArr4, Decl(arrayFromAsync.ts, 28, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) function Data (n) {} @@ -126,9 +126,9 @@ Data.fromAsync = Array.fromAsync; >Data.fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) >Data : Symbol(Data, Decl(arrayFromAsync.ts, 28, 52)) >fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) const sameArr5 = await Data.fromAsync(asyncGen(4)); >sameArr5 : Symbol(sameArr5, Decl(arrayFromAsync.ts, 32, 5)) @@ -139,18 +139,18 @@ const sameArr5 = await Data.fromAsync(asyncGen(4)); const mapArr1 = await Array.fromAsync(asyncGen(4), v => v ** 2); >mapArr1 : Symbol(mapArr1, Decl(arrayFromAsync.ts, 34, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) >v : Symbol(v, Decl(arrayFromAsync.ts, 34, 50)) >v : Symbol(v, Decl(arrayFromAsync.ts, 34, 50)) const mapArr2 = await Array.fromAsync([0,2,4,6], v => Promise.resolve(v ** 2)); >mapArr2 : Symbol(mapArr2, Decl(arrayFromAsync.ts, 35, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >v : Symbol(v, Decl(arrayFromAsync.ts, 35, 48)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) @@ -159,9 +159,9 @@ const mapArr2 = await Array.fromAsync([0,2,4,6], v => Promise.resolve(v ** 2)); const mapArr3 = await Array.fromAsync([0,2,4,6], v => v ** 2); >mapArr3 : Symbol(mapArr3, Decl(arrayFromAsync.ts, 36, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >v : Symbol(v, Decl(arrayFromAsync.ts, 36, 48)) >v : Symbol(v, Decl(arrayFromAsync.ts, 36, 48)) @@ -180,16 +180,16 @@ const badIterable = { [Symbol.iterator] () { throw err; } }; // This returns a promise that will reject with `err`. const badArray = await Array.fromAsync(badIterable); >badArray : Symbol(badArray, Decl(arrayFromAsync.ts, 41, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >badIterable : Symbol(badIterable, Decl(arrayFromAsync.ts, 39, 5)) const withIndexResult = await Array.fromAsync(["a", "b"], (str, index) => ({ index, str })); >withIndexResult : Symbol(withIndexResult, Decl(arrayFromAsync.ts, 43, 5)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >str : Symbol(str, Decl(arrayFromAsync.ts, 43, 59)) >index : Symbol(index, Decl(arrayFromAsync.ts, 43, 63)) >index : Symbol(index, Decl(arrayFromAsync.ts, 43, 76)) diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsync.types b/tsc/testdata/baselines/reference/compiler/arrayFromAsync.types index 198529b28bc9f..a008c1fa59802 100644 --- a/tsc/testdata/baselines/reference/compiler/arrayFromAsync.types +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsync.types @@ -110,18 +110,18 @@ const sameArr1 = await Array.fromAsync(arrLike); >sameArr1 : number[] >await Array.fromAsync(arrLike) : number[] >Array.fromAsync(arrLike) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >arrLike : { 0: Promise; 1: Promise; 2: Promise; 3: Promise; length: number; } const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]); >sameArr2 : number[] >await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]) : number[] >Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >[Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)] : Promise[] >Promise.resolve(0) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } @@ -148,9 +148,9 @@ const sameArr3 = await Array.fromAsync(genPromises(4)); >sameArr3 : number[] >await Array.fromAsync(genPromises(4)) : number[] >Array.fromAsync(genPromises(4)) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >genPromises(4) : Generator, void, unknown> >genPromises : (n: any) => Generator, void, unknown> >4 : 4 @@ -159,33 +159,33 @@ const sameArr4 = await Array.fromAsync(asyncGen(4)); >sameArr4 : number[] >await Array.fromAsync(asyncGen(4)) : number[] >Array.fromAsync(asyncGen(4)) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >asyncGen(4) : AsyncGenerator >asyncGen : (n: any) => AsyncGenerator >4 : 4 function Data (n) {} ->Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } +>Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } >n : any Data.fromAsync = Array.fromAsync; ->Data.fromAsync = Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } ->Data.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } ->Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Data.fromAsync = Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Data.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } const sameArr5 = await Data.fromAsync(asyncGen(4)); >sameArr5 : number[] >await Data.fromAsync(asyncGen(4)) : number[] >Data.fromAsync(asyncGen(4)) : Promise ->Data.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } ->Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Data.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Data : { (n: any): void; fromAsync: { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; }; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >asyncGen(4) : AsyncGenerator >asyncGen : (n: any) => AsyncGenerator >4 : 4 @@ -194,9 +194,9 @@ const mapArr1 = await Array.fromAsync(asyncGen(4), v => v ** 2); >mapArr1 : number[] >await Array.fromAsync(asyncGen(4), v => v ** 2) : number[] >Array.fromAsync(asyncGen(4), v => v ** 2) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >asyncGen(4) : AsyncGenerator >asyncGen : (n: any) => AsyncGenerator >4 : 4 @@ -210,9 +210,9 @@ const mapArr2 = await Array.fromAsync([0,2,4,6], v => Promise.resolve(v ** 2)); >mapArr2 : number[] >await Array.fromAsync([0,2,4,6], v => Promise.resolve(v ** 2)) : number[] >Array.fromAsync([0,2,4,6], v => Promise.resolve(v ** 2)) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >[0,2,4,6] : number[] >0 : 0 >2 : 2 @@ -232,9 +232,9 @@ const mapArr3 = await Array.fromAsync([0,2,4,6], v => v ** 2); >mapArr3 : number[] >await Array.fromAsync([0,2,4,6], v => v ** 2) : number[] >Array.fromAsync([0,2,4,6], v => v ** 2) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >[0,2,4,6] : number[] >0 : 0 >2 : 2 @@ -265,18 +265,18 @@ const badArray = await Array.fromAsync(badIterable); >badArray : unknown[] >await Array.fromAsync(badIterable) : unknown[] >Array.fromAsync(badIterable) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >badIterable : { [Symbol.iterator](): never; } const withIndexResult = await Array.fromAsync(["a", "b"], (str, index) => ({ index, str })); >withIndexResult : { index: number; str: string; }[] >await Array.fromAsync(["a", "b"], (str, index) => ({ index, str })) : { index: number; str: string; }[] >Array.fromAsync(["a", "b"], (str, index) => ({ index, str })) : Promise<{ index: number; str: string; }[]> ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >["a", "b"] : string[] >"a" : "a" >"b" : "b" diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.errors.txt b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.errors.txt new file mode 100644 index 0000000000000..5f72ef5ab89e5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.errors.txt @@ -0,0 +1,72 @@ +arrayFromAsyncMapperInput.ts(19,45): error TS2339: Property 'toFixed' does not exist on type 'Promise'. +arrayFromAsyncMapperInput.ts(20,23): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(value: string) => string' is not assignable to parameter of type '(value: string | Promise, index: number) => string'. + Types of parameters 'value' and 'value' are incompatible. + Type 'string | Promise' is not assignable to type 'string'. + Type 'Promise' is not assignable to type 'string'. +arrayFromAsyncMapperInput.ts(21,24): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(value: number) => string' is not assignable to parameter of type '(value: number | Promise, index: number) => string'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number | Promise' is not assignable to type 'number'. + Type 'Promise' is not assignable to type 'number'. +arrayFromAsyncMapperInput.ts(22,32): error TS2769: No overload matches this call. + The last overload gave the following error. + Argument of type '(value: number) => string' is not assignable to parameter of type '(value: number | Promise, index: number) => string'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number | Promise' is not assignable to type 'number'. + Type 'Promise' is not assignable to type 'number'. + + +==== arrayFromAsyncMapperInput.ts (4 errors) ==== + declare const asyncSource: AsyncIterable>; + declare const syncSource: Iterable>; + declare const arrayLike: ArrayLike>; + declare const mixed: typeof asyncSource | typeof syncSource; + declare const explicitMixed: AsyncIterable | Iterable; + declare const optionalAsync: typeof syncSource & Partial; + declare const dual: typeof asyncSource & Iterable; + + const fromAsync: Promise = Array.fromAsync(asyncSource, value => value); + const fromSync: Promise = Array.fromAsync(syncSource, value => value.toFixed()); + const fromArrayLike: Promise = Array.fromAsync(arrayLike, value => value.toFixed()); + const fromString: Promise = Array.fromAsync("ab", value => value.toUpperCase()); + const fromMixed: Promise = Array.fromAsync(mixed, async value => (await value) + 1); + const fromExplicitMixed: Promise = Array.fromAsync(explicitMixed, value => value.toFixed()); + const fromOptionalAsync: Promise = Array.fromAsync(optionalAsync, async value => (await value) + 1); + const fromDual: Promise = Array.fromAsync(dual, value => value); + const unmapped: Promise[]> = Array.fromAsync(asyncSource); + + Array.fromAsync(asyncSource, value => value.toFixed()); + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'Promise'. +!!! related TS2773 arrayFromAsyncMapperInput.ts:19:45: Did you forget to use 'await'? + Array.fromAsync(dual, (value: string) => value.toUpperCase()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(value: string) => string' is not assignable to parameter of type '(value: string | Promise, index: number) => string'. +!!! error TS2769: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2769: Type 'string | Promise' is not assignable to type 'string'. +!!! error TS2769: Type 'Promise' is not assignable to type 'string'. +!!! related TS2771 lib.es2026.array.d.ts:--:--: The last overload is declared here. + Array.fromAsync(mixed, (value: number) => value.toFixed()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(value: number) => string' is not assignable to parameter of type '(value: number | Promise, index: number) => string'. +!!! error TS2769: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2769: Type 'number | Promise' is not assignable to type 'number'. +!!! error TS2769: Type 'Promise' is not assignable to type 'number'. +!!! related TS2771 lib.es2026.array.d.ts:--:--: The last overload is declared here. + Array.fromAsync(optionalAsync, (value: number) => value.toFixed()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: The last overload gave the following error. +!!! error TS2769: Argument of type '(value: number) => string' is not assignable to parameter of type '(value: number | Promise, index: number) => string'. +!!! error TS2769: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2769: Type 'number | Promise' is not assignable to type 'number'. +!!! error TS2769: Type 'Promise' is not assignable to type 'number'. +!!! related TS2771 lib.es2026.array.d.ts:--:--: The last overload is declared here. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.symbols b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.symbols new file mode 100644 index 0000000000000..ae5081019a840 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.symbols @@ -0,0 +1,173 @@ +//// [tests/cases/compiler/arrayFromAsyncMapperInput.ts] //// + +=== arrayFromAsyncMapperInput.ts === +declare const asyncSource: AsyncIterable>; +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) +>AsyncIterable : Symbol(AsyncIterable, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + +declare const syncSource: Iterable>; +>syncSource : Symbol(syncSource, Decl(arrayFromAsyncMapperInput.ts, 1, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + +declare const arrayLike: ArrayLike>; +>arrayLike : Symbol(arrayLike, Decl(arrayFromAsyncMapperInput.ts, 2, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + +declare const mixed: typeof asyncSource | typeof syncSource; +>mixed : Symbol(mixed, Decl(arrayFromAsyncMapperInput.ts, 3, 13)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) +>syncSource : Symbol(syncSource, Decl(arrayFromAsyncMapperInput.ts, 1, 13)) + +declare const explicitMixed: AsyncIterable | Iterable; +>explicitMixed : Symbol(explicitMixed, Decl(arrayFromAsyncMapperInput.ts, 4, 13)) +>AsyncIterable : Symbol(AsyncIterable, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + +declare const optionalAsync: typeof syncSource & Partial; +>optionalAsync : Symbol(optionalAsync, Decl(arrayFromAsyncMapperInput.ts, 5, 13)) +>syncSource : Symbol(syncSource, Decl(arrayFromAsyncMapperInput.ts, 1, 13)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) + +declare const dual: typeof asyncSource & Iterable; +>dual : Symbol(dual, Decl(arrayFromAsyncMapperInput.ts, 6, 13)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + +const fromAsync: Promise = Array.fromAsync(asyncSource, value => value); +>fromAsync : Symbol(fromAsync, Decl(arrayFromAsyncMapperInput.ts, 8, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 8, 65)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 8, 65)) + +const fromSync: Promise = Array.fromAsync(syncSource, value => value.toFixed()); +>fromSync : Symbol(fromSync, Decl(arrayFromAsyncMapperInput.ts, 9, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>syncSource : Symbol(syncSource, Decl(arrayFromAsyncMapperInput.ts, 1, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 9, 63)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 9, 63)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +const fromArrayLike: Promise = Array.fromAsync(arrayLike, value => value.toFixed()); +>fromArrayLike : Symbol(fromArrayLike, Decl(arrayFromAsyncMapperInput.ts, 10, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>arrayLike : Symbol(arrayLike, Decl(arrayFromAsyncMapperInput.ts, 2, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 10, 67)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 10, 67)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +const fromString: Promise = Array.fromAsync("ab", value => value.toUpperCase()); +>fromString : Symbol(fromString, Decl(arrayFromAsyncMapperInput.ts, 11, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 11, 59)) +>value.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 11, 59)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +const fromMixed: Promise = Array.fromAsync(mixed, async value => (await value) + 1); +>fromMixed : Symbol(fromMixed, Decl(arrayFromAsyncMapperInput.ts, 12, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>mixed : Symbol(mixed, Decl(arrayFromAsyncMapperInput.ts, 3, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 12, 65)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 12, 65)) + +const fromExplicitMixed: Promise = Array.fromAsync(explicitMixed, value => value.toFixed()); +>fromExplicitMixed : Symbol(fromExplicitMixed, Decl(arrayFromAsyncMapperInput.ts, 13, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>explicitMixed : Symbol(explicitMixed, Decl(arrayFromAsyncMapperInput.ts, 4, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 13, 91)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 13, 91)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +const fromOptionalAsync: Promise = Array.fromAsync(optionalAsync, async value => (await value) + 1); +>fromOptionalAsync : Symbol(fromOptionalAsync, Decl(arrayFromAsyncMapperInput.ts, 14, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>optionalAsync : Symbol(optionalAsync, Decl(arrayFromAsyncMapperInput.ts, 5, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 14, 81)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 14, 81)) + +const fromDual: Promise = Array.fromAsync(dual, value => value); +>fromDual : Symbol(fromDual, Decl(arrayFromAsyncMapperInput.ts, 15, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>dual : Symbol(dual, Decl(arrayFromAsyncMapperInput.ts, 6, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 15, 57)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 15, 57)) + +const unmapped: Promise[]> = Array.fromAsync(asyncSource); +>unmapped : Symbol(unmapped, Decl(arrayFromAsyncMapperInput.ts, 16, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) + +Array.fromAsync(asyncSource, value => value.toFixed()); +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>asyncSource : Symbol(asyncSource, Decl(arrayFromAsyncMapperInput.ts, 0, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 18, 28)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 18, 28)) + +Array.fromAsync(dual, (value: string) => value.toUpperCase()); +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>dual : Symbol(dual, Decl(arrayFromAsyncMapperInput.ts, 6, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 19, 23)) +>value.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 19, 23)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + +Array.fromAsync(mixed, (value: number) => value.toFixed()); +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>mixed : Symbol(mixed, Decl(arrayFromAsyncMapperInput.ts, 3, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 20, 24)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 20, 24)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +Array.fromAsync(optionalAsync, (value: number) => value.toFixed()); +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>optionalAsync : Symbol(optionalAsync, Decl(arrayFromAsyncMapperInput.ts, 5, 13)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 21, 32)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncMapperInput.ts, 21, 32)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.types b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.types new file mode 100644 index 0000000000000..9fae388f0bd66 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncMapperInput.types @@ -0,0 +1,197 @@ +//// [tests/cases/compiler/arrayFromAsyncMapperInput.ts] //// + +=== arrayFromAsyncMapperInput.ts === +declare const asyncSource: AsyncIterable>; +>asyncSource : AsyncIterable> + +declare const syncSource: Iterable>; +>syncSource : Iterable> + +declare const arrayLike: ArrayLike>; +>arrayLike : ArrayLike> + +declare const mixed: typeof asyncSource | typeof syncSource; +>mixed : AsyncIterable> | Iterable> +>asyncSource : AsyncIterable> +>syncSource : Iterable> + +declare const explicitMixed: AsyncIterable | Iterable; +>explicitMixed : AsyncIterable | Iterable + +declare const optionalAsync: typeof syncSource & Partial; +>optionalAsync : Iterable> & Partial>> +>syncSource : Iterable> +>asyncSource : AsyncIterable> + +declare const dual: typeof asyncSource & Iterable; +>dual : AsyncIterable> & Iterable +>asyncSource : AsyncIterable> + +const fromAsync: Promise = Array.fromAsync(asyncSource, value => value); +>fromAsync : Promise +>Array.fromAsync(asyncSource, value => value) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>asyncSource : AsyncIterable> +>value => value : (value: Promise) => Promise +>value : Promise +>value : Promise + +const fromSync: Promise = Array.fromAsync(syncSource, value => value.toFixed()); +>fromSync : Promise +>Array.fromAsync(syncSource, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>syncSource : Iterable> +>value => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +const fromArrayLike: Promise = Array.fromAsync(arrayLike, value => value.toFixed()); +>fromArrayLike : Promise +>Array.fromAsync(arrayLike, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>arrayLike : ArrayLike> +>value => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +const fromString: Promise = Array.fromAsync("ab", value => value.toUpperCase()); +>fromString : Promise +>Array.fromAsync("ab", value => value.toUpperCase()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>"ab" : "ab" +>value => value.toUpperCase() : (value: string) => string +>value : string +>value.toUpperCase() : string +>value.toUpperCase : () => string +>value : string +>toUpperCase : () => string + +const fromMixed: Promise = Array.fromAsync(mixed, async value => (await value) + 1); +>fromMixed : Promise +>Array.fromAsync(mixed, async value => (await value) + 1) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>mixed : AsyncIterable> | Iterable> +>async value => (await value) + 1 : (value: number | Promise) => Promise +>value : number | Promise +>(await value) + 1 : number +>(await value) : number +>await value : number +>value : number | Promise +>1 : 1 + +const fromExplicitMixed: Promise = Array.fromAsync(explicitMixed, value => value.toFixed()); +>fromExplicitMixed : Promise +>Array.fromAsync(explicitMixed, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>explicitMixed : AsyncIterable | Iterable +>value => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +const fromOptionalAsync: Promise = Array.fromAsync(optionalAsync, async value => (await value) + 1); +>fromOptionalAsync : Promise +>Array.fromAsync(optionalAsync, async value => (await value) + 1) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>optionalAsync : Iterable> & Partial>> +>async value => (await value) + 1 : (value: number | Promise) => Promise +>value : number | Promise +>(await value) + 1 : number +>(await value) : number +>await value : number +>value : number | Promise +>1 : 1 + +const fromDual: Promise = Array.fromAsync(dual, value => value); +>fromDual : Promise +>Array.fromAsync(dual, value => value) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>dual : AsyncIterable> & Iterable +>value => value : (value: Promise) => Promise +>value : Promise +>value : Promise + +const unmapped: Promise[]> = Array.fromAsync(asyncSource); +>unmapped : Promise[]> +>Array.fromAsync(asyncSource) : Promise[]> +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>asyncSource : AsyncIterable> + +Array.fromAsync(asyncSource, value => value.toFixed()); +>Array.fromAsync(asyncSource, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>asyncSource : AsyncIterable> +>value => value.toFixed() : (value: Promise) => any +>value : Promise +>value.toFixed() : any +>value.toFixed : any +>value : Promise +>toFixed : any + +Array.fromAsync(dual, (value: string) => value.toUpperCase()); +>Array.fromAsync(dual, (value: string) => value.toUpperCase()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>dual : AsyncIterable> & Iterable +>(value: string) => value.toUpperCase() : (value: string) => string +>value : string +>value.toUpperCase() : string +>value.toUpperCase : () => string +>value : string +>toUpperCase : () => string + +Array.fromAsync(mixed, (value: number) => value.toFixed()); +>Array.fromAsync(mixed, (value: number) => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>mixed : AsyncIterable> | Iterable> +>(value: number) => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +Array.fromAsync(optionalAsync, (value: number) => value.toFixed()); +>Array.fromAsync(optionalAsync, (value: number) => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>optionalAsync : Iterable> & Partial>> +>(value: number) => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.errors.txt b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.errors.txt new file mode 100644 index 0000000000000..9226b9a227fdb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.errors.txt @@ -0,0 +1,16 @@ +arrayFromAsyncNullishProtocol.ts(8,38): error TS2339: Property 'toFixed' does not exist on type 'Promise'. + + +==== arrayFromAsyncNullishProtocol.ts (1 errors) ==== + const withNull = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: null }); + const withUndefined = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: undefined }); + const fromNull: Promise = Array.fromAsync(withNull, value => value.toFixed()); + const fromUndefined: Promise = Array.fromAsync(withUndefined, value => value.toFixed()); + + declare const dual: AsyncIterable> & Iterable; + const fromDual: Promise = Array.fromAsync(dual, value => value); + Array.fromAsync(dual, value => value.toFixed()); + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'Promise'. +!!! related TS2773 arrayFromAsyncNullishProtocol.ts:8:38: Did you forget to use 'await'? + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.symbols b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.symbols new file mode 100644 index 0000000000000..75829795628d3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.symbols @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/arrayFromAsyncNullishProtocol.ts] //// + +=== arrayFromAsyncNullishProtocol.ts === +const withNull = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: null }); +>withNull : Symbol(withNull, Decl(arrayFromAsyncNullishProtocol.ts, 0, 5)) +>Object.assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>[Symbol.asyncIterator] : Symbol([Symbol.asyncIterator], Decl(arrayFromAsyncNullishProtocol.ts, 0, 54)) +>Symbol.asyncIterator : Symbol(SymbolConstructor.asyncIterator, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) +>asyncIterator : Symbol(SymbolConstructor.asyncIterator, Decl(lib.es2018.asynciterable.d.ts, --, --)) + +const withUndefined = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: undefined }); +>withUndefined : Symbol(withUndefined, Decl(arrayFromAsyncNullishProtocol.ts, 1, 5)) +>Object.assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>[Symbol.asyncIterator] : Symbol([Symbol.asyncIterator], Decl(arrayFromAsyncNullishProtocol.ts, 1, 59)) +>Symbol.asyncIterator : Symbol(SymbolConstructor.asyncIterator, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) +>asyncIterator : Symbol(SymbolConstructor.asyncIterator, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>undefined : Symbol(undefined) + +const fromNull: Promise = Array.fromAsync(withNull, value => value.toFixed()); +>fromNull : Symbol(fromNull, Decl(arrayFromAsyncNullishProtocol.ts, 2, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>withNull : Symbol(withNull, Decl(arrayFromAsyncNullishProtocol.ts, 0, 5)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 2, 61)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 2, 61)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +const fromUndefined: Promise = Array.fromAsync(withUndefined, value => value.toFixed()); +>fromUndefined : Symbol(fromUndefined, Decl(arrayFromAsyncNullishProtocol.ts, 3, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>withUndefined : Symbol(withUndefined, Decl(arrayFromAsyncNullishProtocol.ts, 1, 5)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 3, 71)) +>value.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 3, 71)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +declare const dual: AsyncIterable> & Iterable; +>dual : Symbol(dual, Decl(arrayFromAsyncNullishProtocol.ts, 5, 13)) +>AsyncIterable : Symbol(AsyncIterable, Decl(lib.es2018.asynciterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + +const fromDual: Promise = Array.fromAsync(dual, value => value); +>fromDual : Symbol(fromDual, Decl(arrayFromAsyncNullishProtocol.ts, 6, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>dual : Symbol(dual, Decl(arrayFromAsyncNullishProtocol.ts, 5, 13)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 6, 57)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 6, 57)) + +Array.fromAsync(dual, value => value.toFixed()); +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>dual : Symbol(dual, Decl(arrayFromAsyncNullishProtocol.ts, 5, 13)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 7, 21)) +>value : Symbol(value, Decl(arrayFromAsyncNullishProtocol.ts, 7, 21)) + diff --git a/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.types b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.types new file mode 100644 index 0000000000000..7e37038f4b824 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/arrayFromAsyncNullishProtocol.types @@ -0,0 +1,95 @@ +//// [tests/cases/compiler/arrayFromAsyncNullishProtocol.ts] //// + +=== arrayFromAsyncNullishProtocol.ts === +const withNull = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: null }); +>withNull : Promise[] & { [Symbol.asyncIterator]: any; } +>Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: null }) : Promise[] & { [Symbol.asyncIterator]: any; } +>Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>Object : ObjectConstructor +>assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>[Promise.resolve(1)] : Promise[] +>Promise.resolve(1) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>1 : 1 +>{ [Symbol.asyncIterator]: null } : { [Symbol.asyncIterator]: null; } +>[Symbol.asyncIterator] : null +>Symbol.asyncIterator : unique symbol +>Symbol : SymbolConstructor +>asyncIterator : unique symbol + +const withUndefined = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: undefined }); +>withUndefined : Promise[] & { [Symbol.asyncIterator]: any; } +>Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: undefined }) : Promise[] & { [Symbol.asyncIterator]: any; } +>Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>Object : ObjectConstructor +>assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>[Promise.resolve(1)] : Promise[] +>Promise.resolve(1) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +>1 : 1 +>{ [Symbol.asyncIterator]: undefined } : { [Symbol.asyncIterator]: undefined; } +>[Symbol.asyncIterator] : undefined +>Symbol.asyncIterator : unique symbol +>Symbol : SymbolConstructor +>asyncIterator : unique symbol +>undefined : undefined + +const fromNull: Promise = Array.fromAsync(withNull, value => value.toFixed()); +>fromNull : Promise +>Array.fromAsync(withNull, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>withNull : Promise[] & { [Symbol.asyncIterator]: any; } +>value => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +const fromUndefined: Promise = Array.fromAsync(withUndefined, value => value.toFixed()); +>fromUndefined : Promise +>Array.fromAsync(withUndefined, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>withUndefined : Promise[] & { [Symbol.asyncIterator]: any; } +>value => value.toFixed() : (value: number) => string +>value : number +>value.toFixed() : string +>value.toFixed : (fractionDigits?: number) => string +>value : number +>toFixed : (fractionDigits?: number) => string + +declare const dual: AsyncIterable> & Iterable; +>dual : AsyncIterable> & Iterable + +const fromDual: Promise = Array.fromAsync(dual, value => value); +>fromDual : Promise +>Array.fromAsync(dual, value => value) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>dual : AsyncIterable> & Iterable +>value => value : (value: Promise) => Promise +>value : Promise +>value : Promise + +Array.fromAsync(dual, value => value.toFixed()); +>Array.fromAsync(dual, value => value.toFixed()) : Promise +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>dual : AsyncIterable> & Iterable +>value => value.toFixed() : (value: Promise) => any +>value : Promise +>value.toFixed() : any +>value.toFixed : any +>value : Promise +>toFixed : any + diff --git a/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.symbols b/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.symbols index db92d1f52e67e..d19c7a200fe19 100644 --- a/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.symbols +++ b/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.symbols @@ -4,9 +4,9 @@ const resolvedValues: Promise = Array.fromAsync([ >resolvedValues : Symbol(resolvedValues, Decl(arrayFromAsyncES2026.ts, 0, 5)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) Promise.resolve(1), >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) @@ -23,9 +23,9 @@ const resolvedValues: Promise = Array.fromAsync([ const mapped: Promise = Array.fromAsync([1, 2], async value => value.toString()); >mapped : Symbol(mapped, Decl(arrayFromAsyncES2026.ts, 5, 5)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) ->Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) ->fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) +>fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --), Decl(lib.es2026.array.d.ts, --, --)) >value : Symbol(value, Decl(arrayFromAsyncES2026.ts, 5, 63)) >value.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) >value : Symbol(value, Decl(arrayFromAsyncES2026.ts, 5, 63)) diff --git a/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.types b/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.types index 40d48b1860c2a..168d1118882ac 100644 --- a/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.types +++ b/tsc/testdata/baselines/reference/conformance/arrayFromAsyncES2026.types @@ -4,9 +4,9 @@ const resolvedValues: Promise = Array.fromAsync([ >resolvedValues : Promise >Array.fromAsync([ Promise.resolve(1), Promise.resolve(2),]) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >[ Promise.resolve(1), Promise.resolve(2),] : Promise[] Promise.resolve(1), @@ -28,9 +28,9 @@ const resolvedValues: Promise = Array.fromAsync([ const mapped: Promise = Array.fromAsync([1, 2], async value => value.toString()); >mapped : Promise >Array.fromAsync([1, 2], async value => value.toString()) : Promise ->Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >Array : ArrayConstructor ->fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: (Iterable | ArrayLike) & { [Symbol.asyncIterator]?: null | undefined; }, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable, mapFn: (value: T, index: number) => U, thisArg?: any): Promise[]>; (iterableOrArrayLike: AsyncIterable | ((Iterable | ArrayLike) & { [Symbol.asyncIterator]?: AsyncIterable[typeof Symbol.asyncIterator] | null | undefined; }), mapFn: (value: TAsync | Awaited, index: number) => U, thisArg?: any): Promise[]>; } >[1, 2] : number[] >1 : 1 >2 : 2 diff --git a/tsc/testdata/tests/cases/compiler/arrayFromAsyncMapperInput.ts b/tsc/testdata/tests/cases/compiler/arrayFromAsyncMapperInput.ts new file mode 100644 index 0000000000000..ec9d58ebc96d2 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/arrayFromAsyncMapperInput.ts @@ -0,0 +1,26 @@ +// @lib: es2026 +// @strict: true +// @noEmit: true + +declare const asyncSource: AsyncIterable>; +declare const syncSource: Iterable>; +declare const arrayLike: ArrayLike>; +declare const mixed: typeof asyncSource | typeof syncSource; +declare const explicitMixed: AsyncIterable | Iterable; +declare const optionalAsync: typeof syncSource & Partial; +declare const dual: typeof asyncSource & Iterable; + +const fromAsync: Promise = Array.fromAsync(asyncSource, value => value); +const fromSync: Promise = Array.fromAsync(syncSource, value => value.toFixed()); +const fromArrayLike: Promise = Array.fromAsync(arrayLike, value => value.toFixed()); +const fromString: Promise = Array.fromAsync("ab", value => value.toUpperCase()); +const fromMixed: Promise = Array.fromAsync(mixed, async value => (await value) + 1); +const fromExplicitMixed: Promise = Array.fromAsync(explicitMixed, value => value.toFixed()); +const fromOptionalAsync: Promise = Array.fromAsync(optionalAsync, async value => (await value) + 1); +const fromDual: Promise = Array.fromAsync(dual, value => value); +const unmapped: Promise[]> = Array.fromAsync(asyncSource); + +Array.fromAsync(asyncSource, value => value.toFixed()); +Array.fromAsync(dual, (value: string) => value.toUpperCase()); +Array.fromAsync(mixed, (value: number) => value.toFixed()); +Array.fromAsync(optionalAsync, (value: number) => value.toFixed()); diff --git a/tsc/testdata/tests/cases/compiler/arrayFromAsyncNullishProtocol.ts b/tsc/testdata/tests/cases/compiler/arrayFromAsyncNullishProtocol.ts new file mode 100644 index 0000000000000..f1e30e7593be4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/arrayFromAsyncNullishProtocol.ts @@ -0,0 +1,13 @@ +// @lib: es2026 +// @strict: true +// @strictNullChecks: false +// @noEmit: true + +const withNull = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: null }); +const withUndefined = Object.assign([Promise.resolve(1)], { [Symbol.asyncIterator]: undefined }); +const fromNull: Promise = Array.fromAsync(withNull, value => value.toFixed()); +const fromUndefined: Promise = Array.fromAsync(withUndefined, value => value.toFixed()); + +declare const dual: AsyncIterable> & Iterable; +const fromDual: Promise = Array.fromAsync(dual, value => value); +Array.fromAsync(dual, value => value.toFixed());