diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2493a83b33c06..1e95cb4724180 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -233,6 +233,7 @@ const libEntries: [string, string][] = [ ["esnext.weakref", "lib.es2021.weakref.d.ts"], ["esnext.decorators", "lib.esnext.decorators.d.ts"], ["esnext.object", "lib.esnext.object.d.ts"], + ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.regexp", "lib.esnext.regexp.d.ts"], ["decorators", "lib.decorators.d.ts"], ["decorators.legacy", "lib.decorators.legacy.d.ts"], diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 357921a190394..184f68b0c6221 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1338,6 +1338,9 @@ export const getScriptTargetFeatures = /* @__PURE__ */ memoize((): ScriptTargetF "from", "of", ], + esnext: [ + "fromAsync", + ], })), ObjectConstructor: new Map(Object.entries({ es2015: [ diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts new file mode 100644 index 0000000000000..6842e5d0c401a --- /dev/null +++ b/src/lib/esnext.array.d.ts @@ -0,0 +1,17 @@ +interface ArrayConstructor { + /** + * Creates an array from an async iterator or iterable object. + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + */ + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + + /** + * Creates an array from an async iterator or iterable object. + * + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of itarableOrArrayLike. + * 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) => U, thisArg?: any): Promise[]>; +} diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index c10d0978142c1..9e601b60a27c2 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -5,4 +5,5 @@ /// /// /// +/// /// diff --git a/src/lib/libs.json b/src/lib/libs.json index 8d54d5068dea5..d97a25e09679f 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -77,6 +77,7 @@ "esnext.promise", "esnext.object", "esnext.collection", + "esnext.array", "esnext.regexp", "decorators", "decorators.legacy", diff --git a/tests/baselines/reference/arrayFromAsync.js b/tests/baselines/reference/arrayFromAsync.js new file mode 100644 index 0000000000000..7a163820bbfb8 --- /dev/null +++ b/tests/baselines/reference/arrayFromAsync.js @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/arrayFromAsync.ts] //// + +//// [arrayFromAsync.ts] +export { }; +async function * asyncGen (n) { + for (let i = 0; i < n; i++) + yield i * 2; + } + +function * genPromises (n) { + for (let i = 0; i < n; i++) { + yield Promise.resolve(i * 2); + } +} + +const arrLike = { + 0: Promise.resolve(0), + 1: Promise.resolve(2), + 2: Promise.resolve(4), + 3: Promise.resolve(6), + length: 4, +} + +const arr : number[] = []; +for await (const v of asyncGen(4)) { + arr.push(v); +} + +const sameArr1 = await Array.fromAsync(arrLike); +const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]); +const sameArr3 = await Array.fromAsync(genPromises(4)); +const sameArr4 = await Array.fromAsync(asyncGen(4)); + +function Data (n) {} +Data.fromAsync = Array.fromAsync; +const sameArr5 = await Data.fromAsync(asyncGen(4)); + +const mapArr1 = await Array.fromAsync(asyncGen(4), v => v ** 2); +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); + +const err = new Error; +const badIterable = { [Symbol.iterator] () { throw err; } }; +// This returns a promise that will reject with `err`. +const badArray = await Array.fromAsync(badIterable); + +//// [arrayFromAsync.js] +async function* asyncGen(n) { + for (let i = 0; i < n; i++) + yield i * 2; +} +function* genPromises(n) { + for (let i = 0; i < n; i++) { + yield Promise.resolve(i * 2); + } +} +const arrLike = { + 0: Promise.resolve(0), + 1: Promise.resolve(2), + 2: Promise.resolve(4), + 3: Promise.resolve(6), + length: 4, +}; +const arr = []; +for await (const v of asyncGen(4)) { + arr.push(v); +} +const sameArr1 = await Array.fromAsync(arrLike); +const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]); +const sameArr3 = await Array.fromAsync(genPromises(4)); +const sameArr4 = await Array.fromAsync(asyncGen(4)); +function Data(n) { } +Data.fromAsync = Array.fromAsync; +const sameArr5 = await Data.fromAsync(asyncGen(4)); +const mapArr1 = await Array.fromAsync(asyncGen(4), v => v ** 2); +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); +const err = new Error; +const badIterable = { [Symbol.iterator]() { throw err; } }; +// This returns a promise that will reject with `err`. +const badArray = await Array.fromAsync(badIterable); +export {}; diff --git a/tests/baselines/reference/arrayFromAsync.symbols b/tests/baselines/reference/arrayFromAsync.symbols new file mode 100644 index 0000000000000..81154e0a90567 --- /dev/null +++ b/tests/baselines/reference/arrayFromAsync.symbols @@ -0,0 +1,187 @@ +//// [tests/cases/compiler/arrayFromAsync.ts] //// + +=== arrayFromAsync.ts === +export { }; +async function * asyncGen (n) { +>asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) +>n : Symbol(n, Decl(arrayFromAsync.ts, 1, 27)) + + for (let i = 0; i < n; i++) +>i : Symbol(i, Decl(arrayFromAsync.ts, 2, 12)) +>i : Symbol(i, Decl(arrayFromAsync.ts, 2, 12)) +>n : Symbol(n, Decl(arrayFromAsync.ts, 1, 27)) +>i : Symbol(i, Decl(arrayFromAsync.ts, 2, 12)) + + yield i * 2; +>i : Symbol(i, Decl(arrayFromAsync.ts, 2, 12)) + } + +function * genPromises (n) { +>genPromises : Symbol(genPromises, Decl(arrayFromAsync.ts, 4, 3)) +>n : Symbol(n, Decl(arrayFromAsync.ts, 6, 24)) + + for (let i = 0; i < n; i++) { +>i : Symbol(i, Decl(arrayFromAsync.ts, 7, 12)) +>i : Symbol(i, Decl(arrayFromAsync.ts, 7, 12)) +>n : Symbol(n, Decl(arrayFromAsync.ts, 6, 24)) +>i : Symbol(i, Decl(arrayFromAsync.ts, 7, 12)) + + yield Promise.resolve(i * 2); +>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, --, --)) +>i : Symbol(i, Decl(arrayFromAsync.ts, 7, 12)) + } +} + +const arrLike = { +>arrLike : Symbol(arrLike, Decl(arrayFromAsync.ts, 12, 5)) + + 0: Promise.resolve(0), +>0 : Symbol(0, Decl(arrayFromAsync.ts, 12, 17)) +>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, --, --)) + + 1: Promise.resolve(2), +>1 : Symbol(1, Decl(arrayFromAsync.ts, 13, 26)) +>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, --, --)) + + 2: Promise.resolve(4), +>2 : Symbol(2, Decl(arrayFromAsync.ts, 14, 26)) +>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, --, --)) + + 3: Promise.resolve(6), +>3 : Symbol(3, Decl(arrayFromAsync.ts, 15, 26)) +>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, --, --)) + + length: 4, +>length : Symbol(length, Decl(arrayFromAsync.ts, 16, 26)) +} + +const arr : number[] = []; +>arr : Symbol(arr, Decl(arrayFromAsync.ts, 20, 5)) + +for await (const v of asyncGen(4)) { +>v : Symbol(v, Decl(arrayFromAsync.ts, 21, 16)) +>asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) + + arr.push(v); +>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(arrayFromAsync.ts, 20, 5)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>v : Symbol(v, Decl(arrayFromAsync.ts, 21, 16)) +} + +const sameArr1 = await Array.fromAsync(arrLike); +>sameArr1 : Symbol(sameArr1, Decl(arrayFromAsync.ts, 25, 5)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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, --, --)) +>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, --, --)) +>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, --, --)) +>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, --, --)) + +const sameArr3 = await Array.fromAsync(genPromises(4)); +>sameArr3 : Symbol(sameArr3, Decl(arrayFromAsync.ts, 27, 5)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) + +function Data (n) {} +>Data : Symbol(Data, Decl(arrayFromAsync.ts, 28, 52), Decl(arrayFromAsync.ts, 30, 20)) +>n : Symbol(n, Decl(arrayFromAsync.ts, 30, 15)) + +Data.fromAsync = Array.fromAsync; +>Data.fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) +>Data : Symbol(Data, Decl(arrayFromAsync.ts, 28, 52), Decl(arrayFromAsync.ts, 30, 20)) +>fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) +>Array.fromAsync : Symbol(ArrayConstructor.fromAsync, Decl(lib.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) + +const sameArr5 = await Data.fromAsync(asyncGen(4)); +>sameArr5 : Symbol(sameArr5, Decl(arrayFromAsync.ts, 32, 5)) +>Data.fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) +>Data : Symbol(Data, Decl(arrayFromAsync.ts, 28, 52), Decl(arrayFromAsync.ts, 30, 20)) +>fromAsync : Symbol(Data.fromAsync, Decl(arrayFromAsync.ts, 30, 20)) +>asyncGen : Symbol(asyncGen, Decl(arrayFromAsync.ts, 0, 11)) + +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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.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, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>v : Symbol(v, Decl(arrayFromAsync.ts, 35, 48)) + +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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>v : Symbol(v, Decl(arrayFromAsync.ts, 36, 48)) +>v : Symbol(v, Decl(arrayFromAsync.ts, 36, 48)) + +const err = new Error; +>err : Symbol(err, Decl(arrayFromAsync.ts, 38, 5)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) + +const badIterable = { [Symbol.iterator] () { throw err; } }; +>badIterable : Symbol(badIterable, Decl(arrayFromAsync.ts, 39, 5)) +>[Symbol.iterator] : Symbol([Symbol.iterator], Decl(arrayFromAsync.ts, 39, 21)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.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, --, --)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>err : Symbol(err, Decl(arrayFromAsync.ts, 38, 5)) + +// 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.esnext.array.d.ts, --, --), Decl(lib.esnext.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.esnext.array.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>badIterable : Symbol(badIterable, Decl(arrayFromAsync.ts, 39, 5)) + diff --git a/tests/baselines/reference/arrayFromAsync.types b/tests/baselines/reference/arrayFromAsync.types new file mode 100644 index 0000000000000..373922b3c9189 --- /dev/null +++ b/tests/baselines/reference/arrayFromAsync.types @@ -0,0 +1,272 @@ +//// [tests/cases/compiler/arrayFromAsync.ts] //// + +=== arrayFromAsync.ts === +export { }; +async function * asyncGen (n) { +>asyncGen : (n: any) => AsyncGenerator +>n : any + + for (let i = 0; i < n; i++) +>i : number +>0 : 0 +>i < n : boolean +>i : number +>n : any +>i++ : number +>i : number + + yield i * 2; +>yield i * 2 : any +>i * 2 : number +>i : number +>2 : 2 + } + +function * genPromises (n) { +>genPromises : (n: any) => Generator, void, unknown> +>n : any + + for (let i = 0; i < n; i++) { +>i : number +>0 : 0 +>i < n : boolean +>i : number +>n : any +>i++ : number +>i : number + + yield Promise.resolve(i * 2); +>yield Promise.resolve(i * 2) : any +>Promise.resolve(i * 2) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>i * 2 : number +>i : number +>2 : 2 + } +} + +const arrLike = { +>arrLike : { 0: Promise; 1: Promise; 2: Promise; 3: Promise; length: number; } +>{ 0: Promise.resolve(0), 1: Promise.resolve(2), 2: Promise.resolve(4), 3: Promise.resolve(6), length: 4,} : { 0: Promise; 1: Promise; 2: Promise; 3: Promise; length: number; } + + 0: Promise.resolve(0), +>0 : Promise +>Promise.resolve(0) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>0 : 0 + + 1: Promise.resolve(2), +>1 : Promise +>Promise.resolve(2) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>2 : 2 + + 2: Promise.resolve(4), +>2 : Promise +>Promise.resolve(4) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>4 : 4 + + 3: Promise.resolve(6), +>3 : Promise +>Promise.resolve(6) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>6 : 6 + + length: 4, +>length : number +>4 : 4 +} + +const arr : number[] = []; +>arr : number[] +>[] : undefined[] + +for await (const v of asyncGen(4)) { +>v : number +>asyncGen(4) : AsyncGenerator +>asyncGen : (n: any) => AsyncGenerator +>4 : 4 + + arr.push(v); +>arr.push(v) : number +>arr.push : (...items: number[]) => number +>arr : number[] +>push : (...items: number[]) => number +>v : number +} + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => 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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => 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_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>0 : 0 +>Promise.resolve(2) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>2 : 2 +>Promise.resolve(4) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>4 : 4 +>Promise.resolve(6) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>6 : 6 + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>genPromises(4) : Generator, void, unknown> +>genPromises : (n: any) => Generator, void, unknown> +>4 : 4 + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>asyncGen(4) : AsyncGenerator +>asyncGen : (n: any) => AsyncGenerator +>4 : 4 + +function Data (n) {} +>Data : typeof Data +>n : any + +Data.fromAsync = Array.fromAsync; +>Data.fromAsync = Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>Data.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>Data : typeof Data +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>Array.fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => 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) => U, thisArg?: any): Promise[]>; } +>Data : typeof Data +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>asyncGen(4) : AsyncGenerator +>asyncGen : (n: any) => AsyncGenerator +>4 : 4 + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>asyncGen(4) : AsyncGenerator +>asyncGen : (n: any) => AsyncGenerator +>4 : 4 +>v => v ** 2 : (v: number) => number +>v : number +>v ** 2 : number +>v : number +>2 : 2 + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>[0,2,4,6] : number[] +>0 : 0 +>2 : 2 +>4 : 4 +>6 : 6 +>v => Promise.resolve(v ** 2) : (v: number) => Promise +>v : number +>Promise.resolve(v ** 2) : Promise +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>Promise : PromiseConstructor +>resolve : { (): Promise; (value: T): Promise>; (value: T_1 | PromiseLike): Promise>; } +>v ** 2 : number +>v : number +>2 : 2 + +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>[0,2,4,6] : number[] +>0 : 0 +>2 : 2 +>4 : 4 +>6 : 6 +>v => v ** 2 : (v: number) => number +>v : number +>v ** 2 : number +>v : number +>2 : 2 + +const err = new Error; +>err : Error +>new Error : Error +>Error : ErrorConstructor + +const badIterable = { [Symbol.iterator] () { throw err; } }; +>badIterable : { [Symbol.iterator](): never; } +>{ [Symbol.iterator] () { throw err; } } : { [Symbol.iterator](): never; } +>[Symbol.iterator] : () => never +>Symbol.iterator : unique symbol +>Symbol : SymbolConstructor +>iterator : unique symbol +>err : Error + +// This returns a promise that will reject with `err`. +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) => U, thisArg?: any): Promise[]>; } +>Array : ArrayConstructor +>fromAsync : { (iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; (iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } +>badIterable : { [Symbol.iterator](): never; } + diff --git a/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=bundler).trace.json b/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=bundler).trace.json index 6605a7f00d26b..e67efed2af66b 100644 --- a/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=bundler).trace.json +++ b/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=bundler).trace.json @@ -902,6 +902,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=nodenext).trace.json b/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=nodenext).trace.json index 38c996c524093..d20de95869c4e 100644 --- a/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=nodenext).trace.json +++ b/tests/baselines/reference/bundlerDirectoryModule(moduleresolution=nodenext).trace.json @@ -1044,6 +1044,21 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/modulePreserve2.trace.json b/tests/baselines/reference/modulePreserve2.trace.json index 1707b9181c356..a61352c6987bb 100644 --- a/tests/baselines/reference/modulePreserve2.trace.json +++ b/tests/baselines/reference/modulePreserve2.trace.json @@ -851,6 +851,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/modulePreserve3.trace.json b/tests/baselines/reference/modulePreserve3.trace.json index 2d9ff62f190c3..9cf8a63b9832c 100644 --- a/tests/baselines/reference/modulePreserve3.trace.json +++ b/tests/baselines/reference/modulePreserve3.trace.json @@ -782,6 +782,17 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json index 072ae8303ff05..9ebc77e422f76 100644 --- a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json @@ -1160,6 +1160,20 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json index 0ba1365aa3990..0faf9ac8e2d24 100644 --- a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json @@ -1103,6 +1103,21 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json index 7c822555a2aeb..0ef4d5da75fb7 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json @@ -1142,6 +1142,20 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json index 343b329f9dfe3..8f83bd2a0a2ce 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json @@ -937,6 +937,19 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json index df73a8ab04637..f788e1872e618 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json @@ -937,6 +937,19 @@ "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "File '/.ts/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", + "File '/.ts/package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index 7bfbbbea37d86..0da50d90ce6d0 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, es2023.intl, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, esnext.array, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index 847ca0d0f6ddf..948f93ad35f21 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, es2023.intl, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, esnext.array, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 847ca0d0f6ddf..948f93ad35f21 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, es2023.intl, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, esnext.array, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, esnext.regexp, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 017f8e35d47ca..702879601311c 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -887,6 +887,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.emptyTypes.trace.json b/tests/baselines/reference/typesVersions.emptyTypes.trace.json index 6590b66baf33d..85d505c87bd75 100644 --- a/tests/baselines/reference/typesVersions.emptyTypes.trace.json +++ b/tests/baselines/reference/typesVersions.emptyTypes.trace.json @@ -904,6 +904,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.justIndex.trace.json b/tests/baselines/reference/typesVersions.justIndex.trace.json index 136f5242182ec..6e30aa01116de 100644 --- a/tests/baselines/reference/typesVersions.justIndex.trace.json +++ b/tests/baselines/reference/typesVersions.justIndex.trace.json @@ -904,6 +904,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index e90c21952c968..b6d5c83566de1 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -848,6 +848,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index 017f8e35d47ca..702879601311c 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -887,6 +887,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index e90c21952c968..b6d5c83566de1 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -848,6 +848,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index 00d2bfd77861f..d599c9965da5d 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -870,6 +870,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index e8f3b473594d8..b2cb2d83e0c18 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -854,6 +854,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/array' from '/.src/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/array'", + "Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/array' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/regexp' from '/.src/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/cases/compiler/arrayFromAsync.ts b/tests/cases/compiler/arrayFromAsync.ts new file mode 100644 index 0000000000000..98a3c56944328 --- /dev/null +++ b/tests/cases/compiler/arrayFromAsync.ts @@ -0,0 +1,45 @@ +// @module: esnext +// @target: esnext + +export { }; +async function * asyncGen (n) { + for (let i = 0; i < n; i++) + yield i * 2; + } + +function * genPromises (n) { + for (let i = 0; i < n; i++) { + yield Promise.resolve(i * 2); + } +} + +const arrLike = { + 0: Promise.resolve(0), + 1: Promise.resolve(2), + 2: Promise.resolve(4), + 3: Promise.resolve(6), + length: 4, +} + +const arr : number[] = []; +for await (const v of asyncGen(4)) { + arr.push(v); +} + +const sameArr1 = await Array.fromAsync(arrLike); +const sameArr2 = await Array.fromAsync([Promise.resolve(0), Promise.resolve(2), Promise.resolve(4), Promise.resolve(6)]); +const sameArr3 = await Array.fromAsync(genPromises(4)); +const sameArr4 = await Array.fromAsync(asyncGen(4)); + +function Data (n) {} +Data.fromAsync = Array.fromAsync; +const sameArr5 = await Data.fromAsync(asyncGen(4)); + +const mapArr1 = await Array.fromAsync(asyncGen(4), v => v ** 2); +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); + +const err = new Error; +const badIterable = { [Symbol.iterator] () { throw err; } }; +// This returns a promise that will reject with `err`. +const badArray = await Array.fromAsync(badIterable); \ No newline at end of file