From ec5f634f299a42b2fc19db2272f8204a47c6004c Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 22 Sep 2020 17:28:35 +0800 Subject: [PATCH 1/9] Add item method --- src/compiler/commandLineParser.ts | 1 + src/lib/esnext.array.d.ts | 88 +++++++++++++++++++ src/lib/esnext.d.ts | 1 + src/lib/esnext.string.d.ts | 6 ++ src/lib/libs.json | 1 + .../config/convertCompilerOptionsFromJson.ts | 8 +- 6 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 src/lib/esnext.array.d.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index beb601b0b8f6f..5e5a83f85cff7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -72,6 +72,7 @@ namespace ts { ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], + ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.string", "lib.esnext.string.d.ts"], ["esnext.promise", "lib.esnext.promise.d.ts"] ]; diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts new file mode 100644 index 0000000000000..ace687ca91049 --- /dev/null +++ b/src/lib/esnext.array.d.ts @@ -0,0 +1,88 @@ +interface Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): T | undefined; +} + + +interface ReadonlyArray { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): T | undefined; +} + +interface Int8Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Uint8Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Uint8ClampedArray { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Int16Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Uint16Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Int32Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Uint32Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Float32Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} + +interface Float64Array { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): number | undefined; +} diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 36c759ff9123c..10dcba251707f 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,4 +1,5 @@ /// /// /// +/// /// diff --git a/src/lib/esnext.string.d.ts b/src/lib/esnext.string.d.ts index 66971bf84d6cf..df8a49f3be94e 100644 --- a/src/lib/esnext.string.d.ts +++ b/src/lib/esnext.string.d.ts @@ -12,4 +12,10 @@ interface String { * @param replacer A function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): string | undefined; } diff --git a/src/lib/libs.json b/src/lib/libs.json index 574c8b27c3730..7eccfcab4dad5 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -47,6 +47,7 @@ "es2020.string", "es2020.symbol.wellknown", "es2020.intl", + "esnext.array", "esnext.intl", "esnext.string", "esnext.promise", diff --git a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts index d007ccf5f8482..1478d050cefed 100644 --- a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts +++ b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts @@ -295,7 +295,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.bigint', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -326,7 +326,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -357,7 +357,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -388,7 +388,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] From b3daf96e8d83ff3255ec6321e2f0510167177e0d Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 22 Sep 2020 17:31:43 +0800 Subject: [PATCH 2/9] fix jsdoc --- src/lib/esnext.array.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index ace687ca91049..ba0fe1217c746 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -1,6 +1,6 @@ interface Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): T | undefined; @@ -9,7 +9,7 @@ interface Array { interface ReadonlyArray { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): T | undefined; @@ -17,7 +17,7 @@ interface ReadonlyArray { interface Int8Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -25,7 +25,7 @@ interface Int8Array { interface Uint8Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -33,7 +33,7 @@ interface Uint8Array { interface Uint8ClampedArray { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -41,7 +41,7 @@ interface Uint8ClampedArray { interface Int16Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -49,7 +49,7 @@ interface Int16Array { interface Uint16Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -57,7 +57,7 @@ interface Uint16Array { interface Int32Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -65,7 +65,7 @@ interface Int32Array { interface Uint32Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -73,7 +73,7 @@ interface Uint32Array { interface Float32Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; @@ -81,7 +81,7 @@ interface Float32Array { interface Float64Array { /** - * Access string by relative indexing. + * Access item by relative indexing. * @param index index to access. */ item(index: number): number | undefined; From b44a0071314626b215ccd66c2fe162bbebbb5b12 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 22 Sep 2020 21:50:50 +0800 Subject: [PATCH 3/9] accept baseline --- .../reference/importExportInternalComments.symbols | 2 +- .../reference/keyofAndIndexedAccess2.symbols | 12 ++++++------ .../reference/noIterationTypeErrorsInCFA.symbols | 2 +- .../taggedTemplatesWithTypeArguments1.symbols | 2 +- .../reference/typeGuardConstructorNarrowAny.symbols | 2 +- .../typeGuardConstructorPrimitiveTypes.symbols | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/importExportInternalComments.symbols b/tests/baselines/reference/importExportInternalComments.symbols index 87eeb2d31e9c9..e4c5f85d9bd77 100644 --- a/tests/baselines/reference/importExportInternalComments.symbols +++ b/tests/baselines/reference/importExportInternalComments.symbols @@ -4,7 +4,7 @@ declare module "foo"; === tests/cases/compiler/default.ts === /*1*/ export /*2*/ default /*3*/ Array /*4*/; ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) === tests/cases/compiler/index.ts === /*1*/ import /*2*/ D /*3*/, /*4*/ { /*5*/ A /*6*/, /*7*/ B /*8*/ as /*9*/ C /*10*/ } /*11*/ from /*12*/ "foo"; diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.symbols b/tests/baselines/reference/keyofAndIndexedAccess2.symbols index 58b5f470c030b..a061d9f3003e8 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess2.symbols @@ -440,9 +440,9 @@ function fn} | {elements: Array}>(par >fn : Symbol(fn, Decl(keyofAndIndexedAccess2.ts, 115, 69)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 119, 12)) >elements : Symbol(elements, Decl(keyofAndIndexedAccess2.ts, 119, 23)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >elements : Symbol(elements, Decl(keyofAndIndexedAccess2.ts, 119, 51)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 119, 77)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 119, 12)) >cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 119, 86)) @@ -459,7 +459,7 @@ function fn} | {elements: Array}>(par function fn2>(param: T, cb: (element: T[number]) => void) { >fn2 : Symbol(fn2, Decl(keyofAndIndexedAccess2.ts, 121, 1)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 123, 13)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 123, 38)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 123, 13)) >cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 123, 47)) @@ -476,7 +476,7 @@ function fn2>(param: T, cb: (element: T[number]) => void function fn3>(param: T, cb: (element: T[number]) => void) { >fn3 : Symbol(fn3, Decl(keyofAndIndexedAccess2.ts, 125, 1)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 129, 46)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) >cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 129, 55)) @@ -494,12 +494,12 @@ function fn4() { let x: Array[K] = 'abc'; >x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 134, 7)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) let y: ReadonlyArray[K] = 'abc'; >y : Symbol(y, Decl(keyofAndIndexedAccess2.ts, 135, 7)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) >K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) } diff --git a/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols b/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols index 3498f52d456f3..60040c3ed17c4 100644 --- a/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols +++ b/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols @@ -13,7 +13,7 @@ export function doRemove(dds: F | F[]) { if (!Array.isArray(dds)) { >Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) >dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) diff --git a/tests/baselines/reference/taggedTemplatesWithTypeArguments1.symbols b/tests/baselines/reference/taggedTemplatesWithTypeArguments1.symbols index 4cd6dce23e368..f37166423f17c 100644 --- a/tests/baselines/reference/taggedTemplatesWithTypeArguments1.symbols +++ b/tests/baselines/reference/taggedTemplatesWithTypeArguments1.symbols @@ -5,7 +5,7 @@ declare function f(strs: TemplateStringsArray, ...callbacks: Array<(x: T) => >strs : Symbol(strs, Decl(taggedTemplatesWithTypeArguments1.ts, 0, 22)) >TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.es5.d.ts, --, --)) >callbacks : Symbol(callbacks, Decl(taggedTemplatesWithTypeArguments1.ts, 0, 49)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >x : Symbol(x, Decl(taggedTemplatesWithTypeArguments1.ts, 0, 71)) >T : Symbol(T, Decl(taggedTemplatesWithTypeArguments1.ts, 0, 19)) diff --git a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols index acbc179aa270d..88c2e6893d0f6 100644 --- a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols +++ b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols @@ -26,7 +26,7 @@ if (var1.constructor === Boolean) { } if (var1.constructor === Array) { >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) var1; // any[] >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) diff --git a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols index 1bcc2f586eb5e..699026eb4781d 100644 --- a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols +++ b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols @@ -34,7 +34,7 @@ if (var1.constructor === Array) { >var1.constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) >constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) var1; // any[] >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) From 93ee38fe86f3b3b43ad8d3838c7c6ad4c1cf39a2 Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 9 Jun 2021 12:02:41 +0800 Subject: [PATCH 4/9] Rename item method --- src/compiler/commandLineParser.ts | 4 ++-- src/lib/es2021.string.d.ts | 6 ----- src/lib/esnext.array.d.ts | 22 ++++++++--------- src/lib/esnext.d.ts | 1 + src/lib/esnext.string.d.ts | 7 ++++++ src/lib/libs.json | 3 ++- .../config/convertCompilerOptionsFromJson.ts | 24 +++++++++++++++---- .../reference/callWithSpread4.symbols | 4 ++-- .../flatArrayNoExcessiveStackDepth.symbols | 2 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- .../typeGuardConstructorNarrowAny.symbols | 2 +- ...typeGuardConstructorPrimitiveTypes.symbols | 6 ++--- 12 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 src/lib/esnext.string.d.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 0897e93a2a80c..93a7deb070108 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -71,15 +71,15 @@ namespace ts { ["es2021.promise", "lib.es2021.promise.d.ts"], ["es2021.string", "lib.es2021.string.d.ts"], ["es2021.weakref", "lib.es2021.weakref.d.ts"], - ["esnext.array", "lib.es2019.array.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.es2021.string.d.ts"], ["esnext.promise", "lib.es2021.promise.d.ts"], ["esnext.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.esnext.array.d.ts"], + ["esnext.string", "lib.esnext.string.d.ts"], ]; /** diff --git a/src/lib/es2021.string.d.ts b/src/lib/es2021.string.d.ts index df8a49f3be94e..66971bf84d6cf 100644 --- a/src/lib/es2021.string.d.ts +++ b/src/lib/es2021.string.d.ts @@ -12,10 +12,4 @@ interface String { * @param replacer A function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; - - /** - * Access string by relative indexing. - * @param index index to access. - */ - item(index: number): string | undefined; } diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index ba0fe1217c746..f7e58a28f156f 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -3,7 +3,7 @@ interface Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): T | undefined; + at(index: number): T | undefined; } @@ -12,7 +12,7 @@ interface ReadonlyArray { * Access item by relative indexing. * @param index index to access. */ - item(index: number): T | undefined; + at(index: number): T | undefined; } interface Int8Array { @@ -20,7 +20,7 @@ interface Int8Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Uint8Array { @@ -28,7 +28,7 @@ interface Uint8Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Uint8ClampedArray { @@ -36,7 +36,7 @@ interface Uint8ClampedArray { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Int16Array { @@ -44,7 +44,7 @@ interface Int16Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Uint16Array { @@ -52,7 +52,7 @@ interface Uint16Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Int32Array { @@ -60,7 +60,7 @@ interface Int32Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Uint32Array { @@ -68,7 +68,7 @@ interface Uint32Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Float32Array { @@ -76,7 +76,7 @@ interface Float32Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } interface Float64Array { @@ -84,5 +84,5 @@ interface Float64Array { * Access item by relative indexing. * @param index index to access. */ - item(index: number): number | undefined; + at(index: number): number | undefined; } diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 5f35a02d5423f..9ad61073d9550 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,3 +1,4 @@ /// /// /// +/// diff --git a/src/lib/esnext.string.d.ts b/src/lib/esnext.string.d.ts new file mode 100644 index 0000000000000..09db1f6372a65 --- /dev/null +++ b/src/lib/esnext.string.d.ts @@ -0,0 +1,7 @@ +interface String { + /** + * Access string by relative indexing. + * @param index index to access. + */ + item(index: number): string | undefined; +} \ No newline at end of file diff --git a/src/lib/libs.json b/src/lib/libs.json index b86aa55a12ab9..3d8f1f1171277 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -51,8 +51,9 @@ "es2021.string", "es2021.promise", "es2021.weakref", - "esnext.array", "esnext.intl", + "esnext.array", + "esnext.string", // Default libraries "es5.full", "es2015.full", diff --git a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts index 760938b57325e..2b9011930e66f 100644 --- a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts +++ b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts @@ -295,7 +295,11 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " + + "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', " + + "'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', " + + "'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', " + + "'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -326,7 +330,11 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " + + "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', " + + "'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', " + + "'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', " + + "'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -357,7 +365,11 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " + + "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', " + + "'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', " + + "'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', " + + "'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -388,7 +400,11 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.array', 'esnext.string', 'esnext.promise'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " + + "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', " + + "'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', " + + "'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', " + + "'esnext.array', 'esnext.string', 'esnext.promise'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/tests/baselines/reference/callWithSpread4.symbols b/tests/baselines/reference/callWithSpread4.symbols index 5c3e96596ef60..da89faff58547 100644 --- a/tests/baselines/reference/callWithSpread4.symbols +++ b/tests/baselines/reference/callWithSpread4.symbols @@ -30,7 +30,7 @@ declare const pli: { (streams: ReadonlyArray): Promise; >streams : Symbol(streams, Decl(callWithSpread4.ts, 5, 5)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) >R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) @@ -43,7 +43,7 @@ declare const pli: { >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) >streams : Symbol(streams, Decl(callWithSpread4.ts, 6, 23)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) diff --git a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols index 4b27f6006cbd7..bbd3083d04c40 100644 --- a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols +++ b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols @@ -15,7 +15,7 @@ const bar = foo.flatMap(bar => bar as Foo); interface Foo extends Array {} >Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) // Repros from comments in #43249 diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 362d9209ea89e..f5a24714db2b3 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -26,7 +26,7 @@ Options: -t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. -m KIND, --module KIND Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. --lib Specify library files to be included in the compilation. - 'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'es2021' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' 'webworker.iterable' 'scripthost' 'es2015.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.array.include' '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' 'es2020.bigint' 'es2020.promise' 'es2020.sharedmemory' 'es2020.string' 'es2020.symbol.wellknown' 'es2020.intl' 'es2021.promise' 'es2021.string' 'es2021.weakref' 'esnext.array' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint' 'esnext.string' 'esnext.promise' 'esnext.weakref' + 'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'es2021' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' 'webworker.iterable' 'scripthost' 'es2015.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.array.include' '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' 'es2020.bigint' 'es2020.promise' 'es2020.sharedmemory' 'es2020.string' 'es2020.symbol.wellknown' 'es2020.intl' 'es2021.promise' 'es2021.string' 'es2021.weakref' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint' 'esnext.promise' 'esnext.weakref' 'esnext.array' 'esnext.string' --allowJs Allow javascript files to be compiled. --jsx KIND Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. -d, --declaration Generates corresponding '.d.ts' file. diff --git a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols index 88c2e6893d0f6..980e68c3f1cf9 100644 --- a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols +++ b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols @@ -5,7 +5,7 @@ let var1: any; if (var1.constructor === String) { >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 5 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 6 more) var1; // String >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) diff --git a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols index 699026eb4781d..7258c198d18f7 100644 --- a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols +++ b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols @@ -7,7 +7,7 @@ if (var1.constructor === String) { >var1.constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) >constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 5 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 6 more) var1; // string >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) @@ -61,7 +61,7 @@ if (var1.constructor === BigInt) { // Narrow a union of primitive object types let var2: String | Number | Boolean | Symbol | BigInt; >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 5 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 6 more) >Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) @@ -71,7 +71,7 @@ if (var2.constructor === String) { >var2.constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) >constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 5 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 6 more) var2; // String >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) From 76e5e03f74ce7ccca58905adbaf28ba00bfbc4f8 Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 9 Jun 2021 12:07:16 +0800 Subject: [PATCH 5/9] Add bigint64 array --- src/lib/esnext.array.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index f7e58a28f156f..f0cde2963d80a 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -86,3 +86,19 @@ interface Float64Array { */ at(index: number): number | undefined; } + +interface BigInt64Array { + /** + * Access item by relative indexing. + * @param index index to access. + */ + at(index: number): bigint | undefined; +} + +interface BigUint64Array { + /** + * Access item by relative indexing. + * @param index index to access. + */ + at(index: number): bigint | undefined; +} From aadb17dd77bba4e70c74fbba0c2f105a9d68119c Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 9 Jun 2021 12:07:42 +0800 Subject: [PATCH 6/9] Add whitespace --- src/lib/esnext.string.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/esnext.string.d.ts b/src/lib/esnext.string.d.ts index 09db1f6372a65..fac0ace15a3a1 100644 --- a/src/lib/esnext.string.d.ts +++ b/src/lib/esnext.string.d.ts @@ -4,4 +4,4 @@ interface String { * @param index index to access. */ item(index: number): string | undefined; -} \ No newline at end of file +} From 33df981e3a6e4224c5fa87c3c89daf02a8aad16a Mon Sep 17 00:00:00 2001 From: Wenlu Wang Date: Wed, 9 Jun 2021 14:07:21 +0800 Subject: [PATCH 7/9] Update src/lib/esnext.string.d.ts Co-authored-by: Anonymous <65428781+CrimsonCodes0@users.noreply.github.com> --- src/lib/esnext.string.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/esnext.string.d.ts b/src/lib/esnext.string.d.ts index fac0ace15a3a1..7a398a35bf95f 100644 --- a/src/lib/esnext.string.d.ts +++ b/src/lib/esnext.string.d.ts @@ -3,5 +3,5 @@ interface String { * Access string by relative indexing. * @param index index to access. */ - item(index: number): string | undefined; + at(index: number): string | undefined; } From 7ee9c40d26b1364e8d52f98ab7e386d472271b94 Mon Sep 17 00:00:00 2001 From: kingwl Date: Thu, 10 Jun 2021 11:44:51 +0800 Subject: [PATCH 8/9] Avoid whitespace --- .../unittests/config/convertCompilerOptionsFromJson.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts index 2b9011930e66f..dfe82c9e74ebd 100644 --- a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts +++ b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts @@ -296,7 +296,7 @@ namespace ts { start: 0, length: 0, messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " + - "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', " + + "'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', " + "'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', " + "'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', " + "'esnext.array', 'esnext.string', 'esnext.promise'.", From 0e27ccbdb7528a02f834c8f9ca1c17c209f34024 Mon Sep 17 00:00:00 2001 From: Wenlu Wang Date: Fri, 9 Jul 2021 14:12:13 +0800 Subject: [PATCH 9/9] Fix lib reference --- src/compiler/commandLineParser.ts | 1 - src/lib/esnext.array.d.ts | 3 ++- src/lib/esnext.string.d.ts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 985791da82fb6..c4a089125dfb4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -71,7 +71,6 @@ namespace ts { ["es2021.promise", "lib.es2021.promise.d.ts"], ["es2021.string", "lib.es2021.string.d.ts"], ["es2021.weakref", "lib.es2021.weakref.d.ts"], - ["es2021.string", "lib.es2021.string.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index f0cde2963d80a..7098ba72865ef 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -1,3 +1,5 @@ +/// + interface Array { /** * Access item by relative indexing. @@ -6,7 +8,6 @@ interface Array { at(index: number): T | undefined; } - interface ReadonlyArray { /** * Access item by relative indexing. diff --git a/src/lib/esnext.string.d.ts b/src/lib/esnext.string.d.ts index 7a398a35bf95f..570a8b617e4cd 100644 --- a/src/lib/esnext.string.d.ts +++ b/src/lib/esnext.string.d.ts @@ -1,3 +1,5 @@ +/// + interface String { /** * Access string by relative indexing.