diff --git a/tsc/internal/bundled/embed_generated.go b/tsc/internal/bundled/embed_generated.go index 53166f01f98d9..4f9253dbdf6df 100644 --- a/tsc/internal/bundled/embed_generated.go +++ b/tsc/internal/bundled/embed_generated.go @@ -211,6 +211,8 @@ var ( libs_lib_esnext_full_d_ts string //go:embed libs/lib.esnext.intl.d.ts libs_lib_esnext_intl_d_ts string + //go:embed libs/lib.esnext.iterator.d.ts + libs_lib_esnext_iterator_d_ts string //go:embed libs/lib.esnext.sharedmemory.d.ts libs_lib_esnext_sharedmemory_d_ts string //go:embed libs/lib.esnext.temporal.d.ts @@ -330,6 +332,7 @@ var embeddedContents = map[string]string{ "libs/lib.esnext.error.d.ts": libs_lib_esnext_error_d_ts, "libs/lib.esnext.full.d.ts": libs_lib_esnext_full_d_ts, "libs/lib.esnext.intl.d.ts": libs_lib_esnext_intl_d_ts, + "libs/lib.esnext.iterator.d.ts": libs_lib_esnext_iterator_d_ts, "libs/lib.esnext.sharedmemory.d.ts": libs_lib_esnext_sharedmemory_d_ts, "libs/lib.esnext.temporal.d.ts": libs_lib_esnext_temporal_d_ts, "libs/lib.esnext.typedarrays.d.ts": libs_lib_esnext_typedarrays_d_ts, @@ -441,6 +444,7 @@ var libsEntries = []fs.DirEntry{ &fileInfo{name: "lib.esnext.error.d.ts", size: int64(len(libs_lib_esnext_error_d_ts))}, &fileInfo{name: "lib.esnext.full.d.ts", size: int64(len(libs_lib_esnext_full_d_ts))}, &fileInfo{name: "lib.esnext.intl.d.ts", size: int64(len(libs_lib_esnext_intl_d_ts))}, + &fileInfo{name: "lib.esnext.iterator.d.ts", size: int64(len(libs_lib_esnext_iterator_d_ts))}, &fileInfo{name: "lib.esnext.sharedmemory.d.ts", size: int64(len(libs_lib_esnext_sharedmemory_d_ts))}, &fileInfo{name: "lib.esnext.temporal.d.ts", size: int64(len(libs_lib_esnext_temporal_d_ts))}, &fileInfo{name: "lib.esnext.typedarrays.d.ts", size: int64(len(libs_lib_esnext_typedarrays_d_ts))}, diff --git a/tsc/internal/bundled/libs/lib.esnext.d.ts b/tsc/internal/bundled/libs/lib.esnext.d.ts index 044947f4d2aa0..d336210d567ba 100644 --- a/tsc/internal/bundled/libs/lib.esnext.d.ts +++ b/tsc/internal/bundled/libs/lib.esnext.d.ts @@ -25,3 +25,4 @@ and limitations under the License. /// /// /// +/// diff --git a/tsc/internal/bundled/libs/lib.esnext.iterator.d.ts b/tsc/internal/bundled/libs/lib.esnext.iterator.d.ts new file mode 100644 index 0000000000000..c2f6a6df2fd54 --- /dev/null +++ b/tsc/internal/bundled/libs/lib.esnext.iterator.d.ts @@ -0,0 +1,116 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + +/// + +export {}; + +interface IteratorZipShortestOptions { + /** + * Stops when any input is exhausted. + */ + mode?: "shortest"; +} + +interface IteratorZipLongestOptions { + /** + * Continues until every input is exhausted. + */ + mode: "longest"; + + /** + * Values used when an input is exhausted before the others. + */ + padding?: T; +} + +interface IteratorZipStrictOptions { + /** + * Requires every input to yield the same number of values. + */ + mode: "strict"; +} + +type IteratorZipOptions = IteratorZipShortestOptions | IteratorZipLongestOptions | IteratorZipStrictOptions; + +type IteratorInput = Iterable | Iterator; + +type IteratorYield> = + T extends Iterable ? U : + T extends Iterator ? U : + never; + +type IteratorZipResult[]> = { + -readonly [K in keyof T]: IteratorYield; +}; + +type IteratorZipKeyedResult }> = { + -readonly [K in keyof T]: IteratorYield; +}; + +declare global { + interface IteratorObject { + /** + * Creates an iterator whose values are arrays containing successive values from this iterator. + * @param chunkSize The maximum number of values in each array. + */ + chunks(chunkSize: number): IteratorObject; + + /** + * Creates a string by concatenating the values of this iterator, separated by the specified separator. + * `null` and `undefined` values contribute an empty string. + * @param separator A string used to separate values. If omitted, a comma is used. + */ + join(separator?: string): string; + + /** + * Determines whether this iterator yields the specified value using SameValueZero comparison. + * @param searchElement The value to locate. + * @param skippedElements The number of values to skip before searching. + */ + includes(searchElement: T, skippedElements?: number): boolean; + } + + interface IteratorConstructor { + /** + * Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable. + * @param iterables An iterable of iterators or iterables to zip. + * @param options Controls how differing input lengths are handled. + */ + zip(iterables: readonly [], options?: IteratorZipOptions>): IteratorObject; + + /** + * Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable. + * @param iterables An iterable of iterators or iterables to zip. + * @param options Controls how differing input lengths are handled. + */ + zip[] | []>(iterables: T, options?: IteratorZipOptions>>>): IteratorObject, undefined, unknown>; + + /** + * Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable. + * @param iterables An iterable of iterators or iterables to zip. + * @param options Controls how differing input lengths are handled. + */ + zip>(iterables: Iterable, options?: IteratorZipOptions>>>): IteratorObject[], undefined, unknown>; + + /** + * Creates an iterator whose values are objects containing values yielded at the same position by each iterator or iterable in the input object. + * @param iterables An object whose enumerable own properties contain iterators or iterables to zip. + * @param options Controls how differing input lengths are handled. + */ + zipKeyed }>(iterables: T, options?: IteratorZipOptions>>>): IteratorObject, undefined, unknown>; + } +} diff --git a/tsc/internal/bundled/libs_generated.go b/tsc/internal/bundled/libs_generated.go index 6750307190f5b..49253b24f900c 100644 --- a/tsc/internal/bundled/libs_generated.go +++ b/tsc/internal/bundled/libs_generated.go @@ -105,6 +105,7 @@ var LibNames = []string{ "lib.esnext.error.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", + "lib.esnext.iterator.d.ts", "lib.esnext.sharedmemory.d.ts", "lib.esnext.temporal.d.ts", "lib.esnext.typedarrays.d.ts", diff --git a/tsc/internal/compiler/program_test.go b/tsc/internal/compiler/program_test.go index 0b91d2ce073e0..615aead0b24ff 100644 --- a/tsc/internal/compiler/program_test.go +++ b/tsc/internal/compiler/program_test.go @@ -111,6 +111,7 @@ var esnextLibs = []string{ "lib.es2025.iterator.d.ts", "lib.es2025.promise.d.ts", "lib.es2025.regexp.d.ts", + "lib.esnext.iterator.d.ts", "lib.esnext.array.d.ts", "lib.esnext.collection.d.ts", "lib.esnext.date.d.ts", diff --git a/tsc/internal/tsoptions/enummaps.go b/tsc/internal/tsoptions/enummaps.go index 3bf67a8640675..2f2982f270182 100644 --- a/tsc/internal/tsoptions/enummaps.go +++ b/tsc/internal/tsoptions/enummaps.go @@ -106,9 +106,9 @@ var LibMap = collections.NewOrderedMapFromList([]collections.MapEntry[string, an {Key: "esnext.regexp", Value: "lib.es2024.regexp.d.ts"}, {Key: "esnext.string", Value: "lib.es2024.string.d.ts"}, {Key: "esnext.float16", Value: "lib.es2025.float16.d.ts"}, - {Key: "esnext.iterator", Value: "lib.es2025.iterator.d.ts"}, {Key: "esnext.promise", Value: "lib.es2025.promise.d.ts"}, // ESNext By-feature options + {Key: "esnext.iterator", Value: "lib.esnext.iterator.d.ts"}, {Key: "esnext.array", Value: "lib.esnext.array.d.ts"}, {Key: "esnext.collection", Value: "lib.esnext.collection.d.ts"}, {Key: "esnext.date", Value: "lib.esnext.date.d.ts"}, diff --git a/tsc/testdata/baselines/reference/compiler/builtinIterator.symbols b/tsc/testdata/baselines/reference/compiler/builtinIterator.symbols index 8cca78ea45700..d85974669fc57 100644 --- a/tsc/testdata/baselines/reference/compiler/builtinIterator.symbols +++ b/tsc/testdata/baselines/reference/compiler/builtinIterator.symbols @@ -184,7 +184,7 @@ const iter1 = Iterator.from(g1); declare const iter2: IteratorObject; >iter2 : Symbol(iter2, Decl(builtinIterator.ts, 71, 13)) ->IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) const iter3 = iter2.flatMap(() => g1); >iter3 : Symbol(iter3, Decl(builtinIterator.ts, 72, 5)) diff --git a/tsc/testdata/baselines/reference/compiler/builtinIterator.types b/tsc/testdata/baselines/reference/compiler/builtinIterator.types index 36094697ac1ef..30a71077c28cf 100644 --- a/tsc/testdata/baselines/reference/compiler/builtinIterator.types +++ b/tsc/testdata/baselines/reference/compiler/builtinIterator.types @@ -4,9 +4,9 @@ const iterator = Iterator.from([0, 1, 2]); >iterator : IteratorObject >Iterator.from([0, 1, 2]) : IteratorObject ->Iterator.from : (value: Iterator | Iterable) => IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject >Iterator : IteratorConstructor ->from : (value: Iterator | Iterable) => IteratorObject +>from : (value: Iterable | Iterator) => IteratorObject >[0, 1, 2] : number[] >0 : 0 >1 : 1 @@ -52,9 +52,9 @@ const zero = iterator.filter(isZero); const iteratorFromBare = Iterator.from({ >iteratorFromBare : IteratorObject >Iterator.from({ next() { return { done: Math.random() < .5, value: "a string", }; },}) : IteratorObject ->Iterator.from : (value: Iterator | Iterable) => IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject >Iterator : IteratorConstructor ->from : (value: Iterator | Iterable) => IteratorObject +>from : (value: Iterable | Iterator) => IteratorObject >{ next() { return { done: Math.random() < .5, value: "a string", }; },} : { next(): { done: boolean; value: string; }; } next() { @@ -244,9 +244,9 @@ declare const g1: Generator; const iter1 = Iterator.from(g1); >iter1 : IteratorObject >Iterator.from(g1) : IteratorObject ->Iterator.from : (value: Iterator | Iterable) => IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject >Iterator : IteratorConstructor ->from : (value: Iterator | Iterable) => IteratorObject +>from : (value: Iterable | Iterator) => IteratorObject >g1 : Generator declare const iter2: IteratorObject; diff --git a/tsc/testdata/baselines/reference/compiler/iteratorChunks.js b/tsc/testdata/baselines/reference/compiler/iteratorChunks.js new file mode 100644 index 0000000000000..7a8ed2e291199 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorChunks.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/iteratorChunks.ts] //// + +//// [iteratorChunks.ts] +const chunks: number[][] = Iterator.from([1, 2, 3]).chunks(2).toArray(); + +// @ts-expect-error chunk size must be a number +Iterator.from([1, 2, 3]).chunks("2"); + + +//// [iteratorChunks.js] +"use strict"; +const chunks = Iterator.from([1, 2, 3]).chunks(2).toArray(); +// @ts-expect-error chunk size must be a number +Iterator.from([1, 2, 3]).chunks("2"); diff --git a/tsc/testdata/baselines/reference/compiler/iteratorChunks.symbols b/tsc/testdata/baselines/reference/compiler/iteratorChunks.symbols new file mode 100644 index 0000000000000..4ba63bd206cc4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorChunks.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/iteratorChunks.ts] //// + +=== iteratorChunks.ts === +const chunks: number[][] = Iterator.from([1, 2, 3]).chunks(2).toArray(); +>chunks : Symbol(chunks, Decl(iteratorChunks.ts, 0, 5)) +>Iterator.from([1, 2, 3]).chunks(2).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.from([1, 2, 3]).chunks : Symbol(IteratorObject.chunks, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>chunks : Symbol(IteratorObject.chunks, Decl(lib.esnext.iterator.d.ts, --, --)) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +// @ts-expect-error chunk size must be a number +Iterator.from([1, 2, 3]).chunks("2"); +>Iterator.from([1, 2, 3]).chunks : Symbol(IteratorObject.chunks, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>chunks : Symbol(IteratorObject.chunks, Decl(lib.esnext.iterator.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorChunks.types b/tsc/testdata/baselines/reference/compiler/iteratorChunks.types new file mode 100644 index 0000000000000..7be86f8bdfe48 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorChunks.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/iteratorChunks.ts] //// + +=== iteratorChunks.ts === +const chunks: number[][] = Iterator.from([1, 2, 3]).chunks(2).toArray(); +>chunks : number[][] +>Iterator.from([1, 2, 3]).chunks(2).toArray() : number[][] +>Iterator.from([1, 2, 3]).chunks(2).toArray : () => number[][] +>Iterator.from([1, 2, 3]).chunks(2) : IteratorObject +>Iterator.from([1, 2, 3]).chunks : (chunkSize: number) => IteratorObject +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>chunks : (chunkSize: number) => IteratorObject +>2 : 2 +>toArray : () => number[][] + +// @ts-expect-error chunk size must be a number +Iterator.from([1, 2, 3]).chunks("2"); +>Iterator.from([1, 2, 3]).chunks("2") : IteratorObject +>Iterator.from([1, 2, 3]).chunks : (chunkSize: number) => IteratorObject +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>chunks : (chunkSize: number) => IteratorObject +>"2" : "2" + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorIncludes.js b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.js new file mode 100644 index 0000000000000..1ea356fb40321 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/iteratorIncludes.ts] //// + +//// [iteratorIncludes.ts] +const includes: boolean = Iterator.from([1, 2, 3]).includes(2); +const includesAfterSkipping: boolean = Iterator.from([1, 2, 3]).includes(2, 1); + +// @ts-expect-error the searched value must match the iterator value +Iterator.from([1, 2, 3]).includes("1"); + +// @ts-expect-error skipped elements must be a number +Iterator.from([1, 2, 3]).includes(2, "1"); + + +//// [iteratorIncludes.js] +"use strict"; +const includes = Iterator.from([1, 2, 3]).includes(2); +const includesAfterSkipping = Iterator.from([1, 2, 3]).includes(2, 1); +// @ts-expect-error the searched value must match the iterator value +Iterator.from([1, 2, 3]).includes("1"); +// @ts-expect-error skipped elements must be a number +Iterator.from([1, 2, 3]).includes(2, "1"); diff --git a/tsc/testdata/baselines/reference/compiler/iteratorIncludes.symbols b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.symbols new file mode 100644 index 0000000000000..0b1fc3aa3aa5d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.symbols @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/iteratorIncludes.ts] //// + +=== iteratorIncludes.ts === +const includes: boolean = Iterator.from([1, 2, 3]).includes(2); +>includes : Symbol(includes, Decl(iteratorIncludes.ts, 0, 5)) +>Iterator.from([1, 2, 3]).includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) + +const includesAfterSkipping: boolean = Iterator.from([1, 2, 3]).includes(2, 1); +>includesAfterSkipping : Symbol(includesAfterSkipping, Decl(iteratorIncludes.ts, 1, 5)) +>Iterator.from([1, 2, 3]).includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) + +// @ts-expect-error the searched value must match the iterator value +Iterator.from([1, 2, 3]).includes("1"); +>Iterator.from([1, 2, 3]).includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) + +// @ts-expect-error skipped elements must be a number +Iterator.from([1, 2, 3]).includes(2, "1"); +>Iterator.from([1, 2, 3]).includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>includes : Symbol(IteratorObject.includes, Decl(lib.esnext.iterator.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorIncludes.types b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.types new file mode 100644 index 0000000000000..66bfdd1da6992 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorIncludes.types @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/iteratorIncludes.ts] //// + +=== iteratorIncludes.ts === +const includes: boolean = Iterator.from([1, 2, 3]).includes(2); +>includes : boolean +>Iterator.from([1, 2, 3]).includes(2) : boolean +>Iterator.from([1, 2, 3]).includes : (searchElement: number, skippedElements?: number) => boolean +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>includes : (searchElement: number, skippedElements?: number) => boolean +>2 : 2 + +const includesAfterSkipping: boolean = Iterator.from([1, 2, 3]).includes(2, 1); +>includesAfterSkipping : boolean +>Iterator.from([1, 2, 3]).includes(2, 1) : boolean +>Iterator.from([1, 2, 3]).includes : (searchElement: number, skippedElements?: number) => boolean +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>includes : (searchElement: number, skippedElements?: number) => boolean +>2 : 2 +>1 : 1 + +// @ts-expect-error the searched value must match the iterator value +Iterator.from([1, 2, 3]).includes("1"); +>Iterator.from([1, 2, 3]).includes("1") : boolean +>Iterator.from([1, 2, 3]).includes : (searchElement: number, skippedElements?: number) => boolean +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>includes : (searchElement: number, skippedElements?: number) => boolean +>"1" : "1" + +// @ts-expect-error skipped elements must be a number +Iterator.from([1, 2, 3]).includes(2, "1"); +>Iterator.from([1, 2, 3]).includes(2, "1") : boolean +>Iterator.from([1, 2, 3]).includes : (searchElement: number, skippedElements?: number) => boolean +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>includes : (searchElement: number, skippedElements?: number) => boolean +>2 : 2 +>"1" : "1" + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorJoin.js b/tsc/testdata/baselines/reference/compiler/iteratorJoin.js new file mode 100644 index 0000000000000..2d8983a916905 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorJoin.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/iteratorJoin.ts] //// + +//// [iteratorJoin.ts] +const joined: string = Iterator.from([1, 2, 3]).join("-"); +const joinedWithDefaultSeparator: string = Iterator.from([1, 2, 3]).join(); + +// @ts-expect-error separator must be a string +Iterator.from([1, 2, 3]).join(0); + + +//// [iteratorJoin.js] +"use strict"; +const joined = Iterator.from([1, 2, 3]).join("-"); +const joinedWithDefaultSeparator = Iterator.from([1, 2, 3]).join(); +// @ts-expect-error separator must be a string +Iterator.from([1, 2, 3]).join(0); diff --git a/tsc/testdata/baselines/reference/compiler/iteratorJoin.symbols b/tsc/testdata/baselines/reference/compiler/iteratorJoin.symbols new file mode 100644 index 0000000000000..d004fb3482b46 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorJoin.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/iteratorJoin.ts] //// + +=== iteratorJoin.ts === +const joined: string = Iterator.from([1, 2, 3]).join("-"); +>joined : Symbol(joined, Decl(iteratorJoin.ts, 0, 5)) +>Iterator.from([1, 2, 3]).join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) + +const joinedWithDefaultSeparator: string = Iterator.from([1, 2, 3]).join(); +>joinedWithDefaultSeparator : Symbol(joinedWithDefaultSeparator, Decl(iteratorJoin.ts, 1, 5)) +>Iterator.from([1, 2, 3]).join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) + +// @ts-expect-error separator must be a string +Iterator.from([1, 2, 3]).join(0); +>Iterator.from([1, 2, 3]).join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator.from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>from : Symbol(IteratorConstructor.from, Decl(lib.es2025.iterator.d.ts, --, --)) +>join : Symbol(IteratorObject.join, Decl(lib.esnext.iterator.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorJoin.types b/tsc/testdata/baselines/reference/compiler/iteratorJoin.types new file mode 100644 index 0000000000000..55ed9784d2056 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorJoin.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/iteratorJoin.ts] //// + +=== iteratorJoin.ts === +const joined: string = Iterator.from([1, 2, 3]).join("-"); +>joined : string +>Iterator.from([1, 2, 3]).join("-") : string +>Iterator.from([1, 2, 3]).join : (separator?: string) => string +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>join : (separator?: string) => string +>"-" : "-" + +const joinedWithDefaultSeparator: string = Iterator.from([1, 2, 3]).join(); +>joinedWithDefaultSeparator : string +>Iterator.from([1, 2, 3]).join() : string +>Iterator.from([1, 2, 3]).join : (separator?: string) => string +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>join : (separator?: string) => string + +// @ts-expect-error separator must be a string +Iterator.from([1, 2, 3]).join(0); +>Iterator.from([1, 2, 3]).join(0) : string +>Iterator.from([1, 2, 3]).join : (separator?: string) => string +>Iterator.from([1, 2, 3]) : IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject +>Iterator : IteratorConstructor +>from : (value: Iterable | Iterator) => IteratorObject +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>join : (separator?: string) => string +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorZip.js b/tsc/testdata/baselines/reference/compiler/iteratorZip.js new file mode 100644 index 0000000000000..5148a43bc92c2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorZip.js @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/iteratorZip.ts] //// + +//// [iteratorZip.ts] +declare const key: unique symbol; + +const tuples: [number, string][] = Iterator.zip([ + [1, 2], + new Set(["a", "b"]), +] as const).toArray(); + +tuples[0][0] = 2; + +Iterator.zip([[1], ["a"]] as const, { mode: "shortest" }); +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [1] }); +Iterator.zip([[1], ["a"]] as const, { mode: "strict" }); + +const empty: never[] = Iterator.zip([]).toArray(); + +declare const iterables: Iterable>; +const arrays: number[][] = Iterator.zip(iterables).toArray(); + +const objects: { a: number; b: string; [key]: boolean; }[] = Iterator.zipKeyed({ + a: [1, 2], + b: new Set(["a", "b"]), + [key]: [true, false], +} as const).toArray(); + +objects[0].a = 2; + +Iterator.zipKeyed({ a: [1], b: ["a"] } as const, { + mode: "longest", + padding: { b: "a" }, +}); + +interface Inputs { + a: Iterable; + b: Iterator; +} + +declare const inputs: Inputs; +const rows: { a: number; b: string; }[] = Iterator.zipKeyed(inputs).toArray(); + +// @ts-expect-error invalid mode +Iterator.zip([[1]], { mode: "invalid" }); + +// @ts-expect-error padding values must match the input element types +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [true] }); + +// @ts-expect-error padding is only used in longest mode +Iterator.zip([[1]], { mode: "shortest", padding: [1] }); + +// @ts-expect-error the input must be iterable +Iterator.zip(0); + +// @ts-expect-error each keyed value must be iterable +Iterator.zipKeyed({ a: 0 }); + + +//// [iteratorZip.js] +"use strict"; +const tuples = Iterator.zip([ + [1, 2], + new Set(["a", "b"]), +]).toArray(); +tuples[0][0] = 2; +Iterator.zip([[1], ["a"]], { mode: "shortest" }); +Iterator.zip([[1], ["a"]], { mode: "longest", padding: [1] }); +Iterator.zip([[1], ["a"]], { mode: "strict" }); +const empty = Iterator.zip([]).toArray(); +const arrays = Iterator.zip(iterables).toArray(); +const objects = Iterator.zipKeyed({ + a: [1, 2], + b: new Set(["a", "b"]), + [key]: [true, false], +}).toArray(); +objects[0].a = 2; +Iterator.zipKeyed({ a: [1], b: ["a"] }, { + mode: "longest", + padding: { b: "a" }, +}); +const rows = Iterator.zipKeyed(inputs).toArray(); +// @ts-expect-error invalid mode +Iterator.zip([[1]], { mode: "invalid" }); +// @ts-expect-error padding values must match the input element types +Iterator.zip([[1], ["a"]], { mode: "longest", padding: [true] }); +// @ts-expect-error padding is only used in longest mode +Iterator.zip([[1]], { mode: "shortest", padding: [1] }); +// @ts-expect-error the input must be iterable +Iterator.zip(0); +// @ts-expect-error each keyed value must be iterable +Iterator.zipKeyed({ a: 0 }); diff --git a/tsc/testdata/baselines/reference/compiler/iteratorZip.symbols b/tsc/testdata/baselines/reference/compiler/iteratorZip.symbols new file mode 100644 index 0000000000000..8ac41ad65154a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorZip.symbols @@ -0,0 +1,181 @@ +//// [tests/cases/compiler/iteratorZip.ts] //// + +=== iteratorZip.ts === +declare const key: unique symbol; +>key : Symbol(key, Decl(iteratorZip.ts, 0, 13)) + +const tuples: [number, string][] = Iterator.zip([ +>tuples : Symbol(tuples, Decl(iteratorZip.ts, 2, 5)) +>Iterator.zip([ [1, 2], new Set(["a", "b"]),] as const).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) + + [1, 2], + new Set(["a", "b"]), +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +] as const).toArray(); +>const : Symbol(const) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +tuples[0][0] = 2; +>tuples : Symbol(tuples, Decl(iteratorZip.ts, 2, 5)) +>0 : Symbol(0) + +Iterator.zip([[1], ["a"]] as const, { mode: "shortest" }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>const : Symbol(const) +>mode : Symbol(mode, Decl(iteratorZip.ts, 9, 37)) + +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [1] }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>const : Symbol(const) +>mode : Symbol(mode, Decl(iteratorZip.ts, 10, 37)) +>padding : Symbol(padding, Decl(iteratorZip.ts, 10, 54)) + +Iterator.zip([[1], ["a"]] as const, { mode: "strict" }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>const : Symbol(const) +>mode : Symbol(mode, Decl(iteratorZip.ts, 11, 37)) + +const empty: never[] = Iterator.zip([]).toArray(); +>empty : Symbol(empty, Decl(iteratorZip.ts, 13, 5)) +>Iterator.zip([]).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +declare const iterables: Iterable>; +>iterables : Symbol(iterables, Decl(iteratorZip.ts, 15, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + +const arrays: number[][] = Iterator.zip(iterables).toArray(); +>arrays : Symbol(arrays, Decl(iteratorZip.ts, 16, 5)) +>Iterator.zip(iterables).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>iterables : Symbol(iterables, Decl(iteratorZip.ts, 15, 13)) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +const objects: { a: number; b: string; [key]: boolean; }[] = Iterator.zipKeyed({ +>objects : Symbol(objects, Decl(iteratorZip.ts, 18, 5)) +>a : Symbol(a, Decl(iteratorZip.ts, 18, 16)) +>b : Symbol(b, Decl(iteratorZip.ts, 18, 27)) +>[key] : Symbol([key], Decl(iteratorZip.ts, 18, 38)) +>key : Symbol(key, Decl(iteratorZip.ts, 0, 13)) +>Iterator.zipKeyed({ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} as const).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) + + a: [1, 2], +>a : Symbol(a, Decl(iteratorZip.ts, 18, 80)) + + b: new Set(["a", "b"]), +>b : Symbol(b, Decl(iteratorZip.ts, 19, 14)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + [key]: [true, false], +>[key] : Symbol([key], Decl(iteratorZip.ts, 20, 27)) +>key : Symbol(key, Decl(iteratorZip.ts, 0, 13)) + +} as const).toArray(); +>const : Symbol(const) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +objects[0].a = 2; +>objects[0].a : Symbol(a, Decl(iteratorZip.ts, 18, 16)) +>objects : Symbol(objects, Decl(iteratorZip.ts, 18, 5)) +>a : Symbol(a, Decl(iteratorZip.ts, 18, 16)) + +Iterator.zipKeyed({ a: [1], b: ["a"] } as const, { +>Iterator.zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>a : Symbol(a, Decl(iteratorZip.ts, 26, 19)) +>b : Symbol(b, Decl(iteratorZip.ts, 26, 27)) +>const : Symbol(const) + + mode: "longest", +>mode : Symbol(mode, Decl(iteratorZip.ts, 26, 50)) + + padding: { b: "a" }, +>padding : Symbol(padding, Decl(iteratorZip.ts, 27, 20)) +>b : Symbol(b, Decl(iteratorZip.ts, 28, 14)) + +}); + +interface Inputs { +>Inputs : Symbol(Inputs, Decl(iteratorZip.ts, 29, 3)) + + a: Iterable; +>a : Symbol(Inputs.a, Decl(iteratorZip.ts, 31, 18)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + + b: Iterator; +>b : Symbol(Inputs.b, Decl(iteratorZip.ts, 32, 24)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +} + +declare const inputs: Inputs; +>inputs : Symbol(inputs, Decl(iteratorZip.ts, 36, 13)) +>Inputs : Symbol(Inputs, Decl(iteratorZip.ts, 29, 3)) + +const rows: { a: number; b: string; }[] = Iterator.zipKeyed(inputs).toArray(); +>rows : Symbol(rows, Decl(iteratorZip.ts, 37, 5)) +>a : Symbol(a, Decl(iteratorZip.ts, 37, 13)) +>b : Symbol(b, Decl(iteratorZip.ts, 37, 24)) +>Iterator.zipKeyed(inputs).toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) +>Iterator.zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>inputs : Symbol(inputs, Decl(iteratorZip.ts, 36, 13)) +>toArray : Symbol(IteratorObject.toArray, Decl(lib.es2025.iterator.d.ts, --, --)) + +// @ts-expect-error invalid mode +Iterator.zip([[1]], { mode: "invalid" }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>mode : Symbol(mode, Decl(iteratorZip.ts, 40, 21)) + +// @ts-expect-error padding values must match the input element types +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [true] }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>const : Symbol(const) +>mode : Symbol(mode, Decl(iteratorZip.ts, 43, 37)) +>padding : Symbol(padding, Decl(iteratorZip.ts, 43, 54)) + +// @ts-expect-error padding is only used in longest mode +Iterator.zip([[1]], { mode: "shortest", padding: [1] }); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>mode : Symbol(mode, Decl(iteratorZip.ts, 46, 21)) +>padding : Symbol(padding, Decl(iteratorZip.ts, 46, 39)) + +// @ts-expect-error the input must be iterable +Iterator.zip(0); +>Iterator.zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zip : Symbol(IteratorConstructor.zip, Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) + +// @ts-expect-error each keyed value must be iterable +Iterator.zipKeyed({ a: 0 }); +>Iterator.zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>zipKeyed : Symbol(IteratorConstructor.zipKeyed, Decl(lib.esnext.iterator.d.ts, --, --)) +>a : Symbol(a, Decl(iteratorZip.ts, 52, 19)) + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorZip.types b/tsc/testdata/baselines/reference/compiler/iteratorZip.types new file mode 100644 index 0000000000000..0ee4392d2b4ef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorZip.types @@ -0,0 +1,279 @@ +//// [tests/cases/compiler/iteratorZip.ts] //// + +=== iteratorZip.ts === +declare const key: unique symbol; +>key : unique symbol + +const tuples: [number, string][] = Iterator.zip([ +>tuples : [number, string][] +>Iterator.zip([ [1, 2], new Set(["a", "b"]),] as const).toArray() : [1 | 2, string][] +>Iterator.zip([ [1, 2], new Set(["a", "b"]),] as const).toArray : () => [1 | 2, string][] +>Iterator.zip([ [1, 2], new Set(["a", "b"]),] as const) : IteratorObject<[1 | 2, string], undefined, unknown> +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[ [1, 2], new Set(["a", "b"]),] as const : [readonly [1, 2], Set] +>[ [1, 2], new Set(["a", "b"]),] : [readonly [1, 2], Set] + + [1, 2], +>[1, 2] : readonly [1, 2] +>1 : 1 +>2 : 2 + + new Set(["a", "b"]), +>new Set(["a", "b"]) : Set +>Set : SetConstructor +>["a", "b"] : string[] +>"a" : "a" +>"b" : "b" + +] as const).toArray(); +>toArray : () => [1 | 2, string][] + +tuples[0][0] = 2; +>tuples[0][0] = 2 : 2 +>tuples[0][0] : number +>tuples[0] : [number, string] +>tuples : [number, string][] +>0 : 0 +>0 : 0 +>2 : 2 + +Iterator.zip([[1], ["a"]] as const, { mode: "shortest" }); +>Iterator.zip([[1], ["a"]] as const, { mode: "shortest" }) : IteratorObject<[1, "a"], undefined, unknown> +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1], ["a"]] as const : [readonly [1], readonly ["a"]] +>[[1], ["a"]] : [readonly [1], readonly ["a"]] +>[1] : readonly [1] +>1 : 1 +>["a"] : readonly ["a"] +>"a" : "a" +>{ mode: "shortest" } : { mode: "shortest"; } +>mode : "shortest" +>"shortest" : "shortest" + +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [1] }); +>Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [1] }) : IteratorObject<[1, "a"], undefined, unknown> +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1], ["a"]] as const : [readonly [1], readonly ["a"]] +>[[1], ["a"]] : [readonly [1], readonly ["a"]] +>[1] : readonly [1] +>1 : 1 +>["a"] : readonly ["a"] +>"a" : "a" +>{ mode: "longest", padding: [1] } : { mode: "longest"; padding: [1]; } +>mode : "longest" +>"longest" : "longest" +>padding : [1] +>[1] : [1] +>1 : 1 + +Iterator.zip([[1], ["a"]] as const, { mode: "strict" }); +>Iterator.zip([[1], ["a"]] as const, { mode: "strict" }) : IteratorObject<[1, "a"], undefined, unknown> +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1], ["a"]] as const : [readonly [1], readonly ["a"]] +>[[1], ["a"]] : [readonly [1], readonly ["a"]] +>[1] : readonly [1] +>1 : 1 +>["a"] : readonly ["a"] +>"a" : "a" +>{ mode: "strict" } : { mode: "strict"; } +>mode : "strict" +>"strict" : "strict" + +const empty: never[] = Iterator.zip([]).toArray(); +>empty : never[] +>Iterator.zip([]).toArray() : never[] +>Iterator.zip([]).toArray : () => never[] +>Iterator.zip([]) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[] : [] +>toArray : () => never[] + +declare const iterables: Iterable>; +>iterables : Iterable> + +const arrays: number[][] = Iterator.zip(iterables).toArray(); +>arrays : number[][] +>Iterator.zip(iterables).toArray() : number[][] +>Iterator.zip(iterables).toArray : () => number[][] +>Iterator.zip(iterables) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>iterables : Iterable> +>toArray : () => number[][] + +const objects: { a: number; b: string; [key]: boolean; }[] = Iterator.zipKeyed({ +>objects : { a: number; b: string; [key]: boolean; }[] +>a : number +>b : string +>[key] : boolean +>key : unique symbol +>Iterator.zipKeyed({ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} as const).toArray() : { a: 1 | 2; b: string; [key]: boolean; }[] +>Iterator.zipKeyed({ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} as const).toArray : () => { a: 1 | 2; b: string; [key]: boolean; }[] +>Iterator.zipKeyed({ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} as const) : IteratorObject<{ a: 1 | 2; b: string; [key]: boolean; }, undefined, unknown> +>Iterator.zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>Iterator : IteratorConstructor +>zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>{ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} as const : { readonly a: readonly [1, 2]; readonly b: Set; readonly [key]: readonly [true, false]; } +>{ a: [1, 2], b: new Set(["a", "b"]), [key]: [true, false],} : { readonly a: readonly [1, 2]; readonly b: Set; readonly [key]: readonly [true, false]; } + + a: [1, 2], +>a : readonly [1, 2] +>[1, 2] : readonly [1, 2] +>1 : 1 +>2 : 2 + + b: new Set(["a", "b"]), +>b : Set +>new Set(["a", "b"]) : Set +>Set : SetConstructor +>["a", "b"] : string[] +>"a" : "a" +>"b" : "b" + + [key]: [true, false], +>[key] : readonly [true, false] +>key : unique symbol +>[true, false] : readonly [true, false] +>true : true +>false : false + +} as const).toArray(); +>toArray : () => { a: 1 | 2; b: string; [key]: boolean; }[] + +objects[0].a = 2; +>objects[0].a = 2 : 2 +>objects[0].a : number +>objects[0] : { a: number; b: string; [key]: boolean; } +>objects : { a: number; b: string; [key]: boolean; }[] +>0 : 0 +>a : number +>2 : 2 + +Iterator.zipKeyed({ a: [1], b: ["a"] } as const, { +>Iterator.zipKeyed({ a: [1], b: ["a"] } as const, { mode: "longest", padding: { b: "a" },}) : IteratorObject<{ a: 1; b: "a"; }, undefined, unknown> +>Iterator.zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>Iterator : IteratorConstructor +>zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>{ a: [1], b: ["a"] } as const : { readonly a: readonly [1]; readonly b: readonly ["a"]; } +>{ a: [1], b: ["a"] } : { readonly a: readonly [1]; readonly b: readonly ["a"]; } +>a : readonly [1] +>[1] : readonly [1] +>1 : 1 +>b : readonly ["a"] +>["a"] : readonly ["a"] +>"a" : "a" +>{ mode: "longest", padding: { b: "a" },} : { mode: "longest"; padding: { b: "a"; }; } + + mode: "longest", +>mode : "longest" +>"longest" : "longest" + + padding: { b: "a" }, +>padding : { b: "a"; } +>{ b: "a" } : { b: "a"; } +>b : "a" +>"a" : "a" + +}); + +interface Inputs { + a: Iterable; +>a : Iterable + + b: Iterator; +>b : Iterator +} + +declare const inputs: Inputs; +>inputs : Inputs + +const rows: { a: number; b: string; }[] = Iterator.zipKeyed(inputs).toArray(); +>rows : { a: number; b: string; }[] +>a : number +>b : string +>Iterator.zipKeyed(inputs).toArray() : { a: number; b: string; }[] +>Iterator.zipKeyed(inputs).toArray : () => { a: number; b: string; }[] +>Iterator.zipKeyed(inputs) : IteratorObject<{ a: number; b: string; }, undefined, unknown> +>Iterator.zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>Iterator : IteratorConstructor +>zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>inputs : Inputs +>toArray : () => { a: number; b: string; }[] + +// @ts-expect-error invalid mode +Iterator.zip([[1]], { mode: "invalid" }); +>Iterator.zip([[1]], { mode: "invalid" }) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1]] : [number[]] +>[1] : number[] +>1 : 1 +>{ mode: "invalid" } : { mode: "invalid"; } +>mode : "invalid" +>"invalid" : "invalid" + +// @ts-expect-error padding values must match the input element types +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [true] }); +>Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [true] }) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1], ["a"]] as const : readonly [readonly [1], readonly ["a"]] +>[[1], ["a"]] : readonly [readonly [1], readonly ["a"]] +>[1] : readonly [1] +>1 : 1 +>["a"] : readonly ["a"] +>"a" : "a" +>{ mode: "longest", padding: [true] } : { mode: "longest"; padding: boolean[]; } +>mode : "longest" +>"longest" : "longest" +>padding : boolean[] +>[true] : boolean[] +>true : true + +// @ts-expect-error padding is only used in longest mode +Iterator.zip([[1]], { mode: "shortest", padding: [1] }); +>Iterator.zip([[1]], { mode: "shortest", padding: [1] }) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>[[1]] : [number[]] +>[1] : number[] +>1 : 1 +>{ mode: "shortest", padding: [1] } : { mode: "shortest"; padding: number[]; } +>mode : "shortest" +>"shortest" : "shortest" +>padding : number[] +>[1] : number[] +>1 : 1 + +// @ts-expect-error the input must be iterable +Iterator.zip(0); +>Iterator.zip(0) : IteratorObject +>Iterator.zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>Iterator : IteratorConstructor +>zip : { (iterables: readonly [], options?: IteratorZipLongestOptions> | IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject; | Iterator)[] | []>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown>; | Iterator>(iterables: Iterable, options?: (IteratorZipLongestOptions ? U : T extends Iterator ? U_1 : never>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined): IteratorObject<(T extends Iterable ? U : T extends Iterator ? U_1 : never)[], undefined, unknown>; } +>0 : 0 + +// @ts-expect-error each keyed value must be iterable +Iterator.zipKeyed({ a: 0 }); +>Iterator.zipKeyed({ a: 0 }) : IteratorObject<{ a: unknown; }, undefined, unknown> +>Iterator.zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>Iterator : IteratorConstructor +>zipKeyed : | Iterator; }>(iterables: T, options?: (IteratorZipLongestOptions ? U : T_1 extends Iterator ? U_1 : never : never : never; }>>> | IteratorZipShortestOptions | IteratorZipStrictOptions) | undefined) => IteratorObject<{ -readonly [K in keyof T]: T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends Iterable ? U : T_1 extends Iterator ? U_1 : never : never : never; }, undefined, unknown> +>{ a: 0 } : { a: number; } +>a : number +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/libReplacement(libreplacement=true).trace.json b/tsc/testdata/baselines/reference/compiler/libReplacement(libreplacement=true).trace.json index 28065b7104c94..e39c415794c97 100644 --- a/tsc/testdata/baselines/reference/compiler/libReplacement(libreplacement=true).trace.json +++ b/tsc/testdata/baselines/reference/compiler/libReplacement(libreplacement=true).trace.json @@ -1090,6 +1090,19 @@ Searching all ancestor node_modules directories for fallback extensions: JavaScr 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/intl' was not resolved. ======== +======== Resolving module '@typescript/lib-esnext/iterator' from '/.src/__lib_node_modules_lookup_lib.esnext.iterator.d.ts__.ts'. ======== +Module resolution kind is not specified, using 'Bundler'. +Resolving in CJS mode with conditions 'require', 'types'. +File '/.src/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +Loading module '@typescript/lib-esnext/iterator' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/.src/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. +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/iterator' was not resolved. ======== ======== Resolving module '@typescript/lib-esnext/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.esnext.sharedmemory.d.ts__.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. diff --git a/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.symbols b/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.symbols index 994515eebf247..2d3dc7de54757 100644 --- a/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.symbols +++ b/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.symbols @@ -7,7 +7,7 @@ declare const i: Iterator; declare const io: IteratorObject; >io : Symbol(io, Decl(awaitUsingDeclarationsWithIteratorObject.ts, 1, 13)) ->IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) declare const g: Generator; >g : Symbol(g, Decl(awaitUsingDeclarationsWithIteratorObject.ts, 2, 13)) diff --git a/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.types b/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.types index dbc6941c863dd..c0f8f32e550de 100644 --- a/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.types +++ b/tsc/testdata/baselines/reference/conformance/awaitUsingDeclarationsWithIteratorObject.types @@ -38,9 +38,9 @@ async function f() { await using it2 = Iterator.from(i) >it2 : IteratorObject >Iterator.from(i) : IteratorObject ->Iterator.from : (value: Iterator | Iterable) => IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject >Iterator : IteratorConstructor ->from : (value: Iterator | Iterable) => IteratorObject +>from : (value: Iterable | Iterator) => IteratorObject >i : Iterator await using it3 = new MyIterator(); diff --git a/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.symbols b/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.symbols index f37a20d478d3b..70dbe2a4bd98f 100644 --- a/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.symbols +++ b/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.symbols @@ -7,7 +7,7 @@ declare const i: Iterator; declare const io: IteratorObject; >io : Symbol(io, Decl(usingDeclarationsWithIteratorObject.ts, 1, 13)) ->IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --)) +>IteratorObject : Symbol(IteratorObject, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.esnext.disposable.d.ts, --, --), Decl(lib.es2025.iterator.d.ts, --, --), Decl(lib.esnext.iterator.d.ts, --, --)) declare const g: Generator; >g : Symbol(g, Decl(usingDeclarationsWithIteratorObject.ts, 2, 13)) diff --git a/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.types b/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.types index 0e8c9344cc652..d166f3b8c2fe2 100644 --- a/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.types +++ b/tsc/testdata/baselines/reference/conformance/usingDeclarationsWithIteratorObject.types @@ -38,9 +38,9 @@ function f() { using it2 = Iterator.from(i) >it2 : IteratorObject >Iterator.from(i) : IteratorObject ->Iterator.from : (value: Iterator | Iterable) => IteratorObject +>Iterator.from : (value: Iterable | Iterator) => IteratorObject >Iterator : IteratorConstructor ->from : (value: Iterator | Iterable) => IteratorObject +>from : (value: Iterable | Iterator) => IteratorObject >i : Iterator using it3 = new MyIterator(); diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/Initialized-TSConfig-with-incorrect-compiler-option-value.js b/tsc/testdata/baselines/reference/tsc/commandLine/Initialized-TSConfig-with-incorrect-compiler-option-value.js index a5717b385b1ad..66b90f5ce5388 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/Initialized-TSConfig-with-incorrect-compiler-option-value.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/Initialized-TSConfig-with-incorrect-compiler-option-value.js @@ -5,5 +5,5 @@ Input:: tsgo --init --lib nonExistLib,es5,es2015.promise ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.promise', 'esnext.iterator', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js b/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js index db9dd22705973..852bf1b5bbaa4 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js @@ -545,7 +545,7 @@ default: react --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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --libReplacement diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/help.js b/tsc/testdata/baselines/reference/tsc/commandLine/help.js index 39b57c563af20..43229367a83ff 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/help.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/help.js @@ -104,7 +104,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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js b/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js index f158bb77874f5..b69dcca51cf8a 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-cannot-provide-terminal-width.js @@ -105,7 +105,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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 2184f188fd065..647ebeb4b034f 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -138,9 +138,9 @@ tsc: The TypeScript Compiler - Version FakeTSVersion xp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024 .object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024 .string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.it - erator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.coll - ection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sh - aredmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy + erator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.col + lection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.s + haredmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined diff --git a/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js b/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js index 0d8d282bf4e12..8df59b6b6c45e 100644 --- a/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js +++ b/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js b/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js index 1554ee4753d44..16a4c1e37e2ea 100644 --- a/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js +++ b/tsc/testdata/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-incorrect-compiler-option-value.js b/tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-incorrect-compiler-option-value.js index 7902a5f89cdfd..c48c19c7e5a51 100644 --- a/tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-incorrect-compiler-option-value.js +++ b/tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-incorrect-compiler-option-value.js @@ -5,5 +5,5 @@ Input:: tsgo --showConfig --lib nonExistLib,es5,es2015.promise ExitStatus:: DiagnosticsPresent_OutputsSkipped Output:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.promise', 'esnext.iterator', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tsc/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js b/tsc/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js index f6ab5b0aed9ea..9116be4108ee0 100644 --- a/tsc/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js +++ b/tsc/testdata/baselines/reference/tscWatch/commandLine/Parse-watch-interval-option-without-tsconfig.json.js @@ -105,7 +105,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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tsc/testdata/baselines/reference/tscWatch/commandLineWatch/watch-handles-tsconfig-deleted.js b/tsc/testdata/baselines/reference/tscWatch/commandLineWatch/watch-handles-tsconfig-deleted.js index 7c3ab632e031c..2d0b542b16a7e 100644 --- a/tsc/testdata/baselines/reference/tscWatch/commandLineWatch/watch-handles-tsconfig-deleted.js +++ b/tsc/testdata/baselines/reference/tscWatch/commandLineWatch/watch-handles-tsconfig-deleted.js @@ -171,7 +171,7 @@ Diff:: incremental reports config read error while clean build without tsconfig - ---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, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy +-one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, 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.arraybuffer, 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.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.iterator, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy -default: undefined - ---allowJs diff --git a/tsc/testdata/baselines/reference/tsoptions/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js b/tsc/testdata/baselines/reference/tsoptions/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js index f959f48966220..e1e22539fa211 100644 --- a/tsc/testdata/baselines/reference/tsoptions/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js +++ b/tsc/testdata/baselines/reference/tsoptions/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js @@ -8,4 +8,4 @@ FileNames:: 0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', '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.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.promise', 'esnext.iterator', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tsc/testdata/tests/cases/compiler/iteratorChunks.ts b/tsc/testdata/tests/cases/compiler/iteratorChunks.ts new file mode 100644 index 0000000000000..0a0ae2213de98 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/iteratorChunks.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @lib: es2015, esnext.iterator +// @strict: true + +const chunks: number[][] = Iterator.from([1, 2, 3]).chunks(2).toArray(); + +// @ts-expect-error chunk size must be a number +Iterator.from([1, 2, 3]).chunks("2"); diff --git a/tsc/testdata/tests/cases/compiler/iteratorIncludes.ts b/tsc/testdata/tests/cases/compiler/iteratorIncludes.ts new file mode 100644 index 0000000000000..f1cc2b41991b0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/iteratorIncludes.ts @@ -0,0 +1,12 @@ +// @target: esnext +// @lib: es2015, esnext.iterator +// @strict: true + +const includes: boolean = Iterator.from([1, 2, 3]).includes(2); +const includesAfterSkipping: boolean = Iterator.from([1, 2, 3]).includes(2, 1); + +// @ts-expect-error the searched value must match the iterator value +Iterator.from([1, 2, 3]).includes("1"); + +// @ts-expect-error skipped elements must be a number +Iterator.from([1, 2, 3]).includes(2, "1"); diff --git a/tsc/testdata/tests/cases/compiler/iteratorJoin.ts b/tsc/testdata/tests/cases/compiler/iteratorJoin.ts new file mode 100644 index 0000000000000..5e5ebee1fc07c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/iteratorJoin.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @lib: es2015, esnext.iterator +// @strict: true + +const joined: string = Iterator.from([1, 2, 3]).join("-"); +const joinedWithDefaultSeparator: string = Iterator.from([1, 2, 3]).join(); + +// @ts-expect-error separator must be a string +Iterator.from([1, 2, 3]).join(0); diff --git a/tsc/testdata/tests/cases/compiler/iteratorZip.ts b/tsc/testdata/tests/cases/compiler/iteratorZip.ts new file mode 100644 index 0000000000000..2b7fda5c88c30 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/iteratorZip.ts @@ -0,0 +1,57 @@ +// @target: esnext +// @lib: es2015, esnext.iterator +// @strict: true + +declare const key: unique symbol; + +const tuples: [number, string][] = Iterator.zip([ + [1, 2], + new Set(["a", "b"]), +] as const).toArray(); + +tuples[0][0] = 2; + +Iterator.zip([[1], ["a"]] as const, { mode: "shortest" }); +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [1] }); +Iterator.zip([[1], ["a"]] as const, { mode: "strict" }); + +const empty: never[] = Iterator.zip([]).toArray(); + +declare const iterables: Iterable>; +const arrays: number[][] = Iterator.zip(iterables).toArray(); + +const objects: { a: number; b: string; [key]: boolean; }[] = Iterator.zipKeyed({ + a: [1, 2], + b: new Set(["a", "b"]), + [key]: [true, false], +} as const).toArray(); + +objects[0].a = 2; + +Iterator.zipKeyed({ a: [1], b: ["a"] } as const, { + mode: "longest", + padding: { b: "a" }, +}); + +interface Inputs { + a: Iterable; + b: Iterator; +} + +declare const inputs: Inputs; +const rows: { a: number; b: string; }[] = Iterator.zipKeyed(inputs).toArray(); + +// @ts-expect-error invalid mode +Iterator.zip([[1]], { mode: "invalid" }); + +// @ts-expect-error padding values must match the input element types +Iterator.zip([[1], ["a"]] as const, { mode: "longest", padding: [true] }); + +// @ts-expect-error padding is only used in longest mode +Iterator.zip([[1]], { mode: "shortest", padding: [1] }); + +// @ts-expect-error the input must be iterable +Iterator.zip(0); + +// @ts-expect-error each keyed value must be iterable +Iterator.zipKeyed({ a: 0 });