From cad1884f22bc2ae28f28cfa693ea016c6ae122b8 Mon Sep 17 00:00:00 2001 From: Scharkee Date: Sat, 15 May 2021 22:06:04 +0300 Subject: [PATCH 1/6] Move formatToParts to es2018 --- src/lib/es2018.intl.d.ts | 11 +++++++++++ src/lib/esnext.intl.d.ts | 13 +------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/es2018.intl.d.ts b/src/lib/es2018.intl.d.ts index 278f404646b41..9f4d473156966 100644 --- a/src/lib/es2018.intl.d.ts +++ b/src/lib/es2018.intl.d.ts @@ -38,4 +38,15 @@ declare namespace Intl { options?: PluralRulesOptions, ): string[]; }; + + type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; + + interface NumberFormatPart { + type: NumberFormatPartTypes; + value: string; + } + + interface NumberFormat { + formatToParts(number?: number): NumberFormatPart[]; + } } diff --git a/src/lib/esnext.intl.d.ts b/src/lib/esnext.intl.d.ts index 2f2f021f8750e..2256fc6268832 100644 --- a/src/lib/esnext.intl.d.ts +++ b/src/lib/esnext.intl.d.ts @@ -1,12 +1 @@ -declare namespace Intl { - type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; - - interface NumberFormatPart { - type: NumberFormatPartTypes; - value: string; - } - - interface NumberFormat { - formatToParts(number?: number | bigint): NumberFormatPart[]; - } -} +declare namespace Intl {} From d480ef1079bda4827d75a8ff08fd624985f9f105 Mon Sep 17 00:00:00 2001 From: Scharkee Date: Sat, 15 May 2021 22:14:22 +0300 Subject: [PATCH 2/6] Change target lib test and target features --- src/compiler/utilities.ts | 4 +--- .../compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 482bc94c150dd..2d36fb2692f09 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -606,6 +606,7 @@ namespace ts { AsyncIterableIterator: emptyArray, AsyncGenerator: emptyArray, AsyncGeneratorFunction: emptyArray, + NumberFormat: ["formatToParts"] }, es2019: { Array: ["flat", "flatMap"], @@ -626,9 +627,6 @@ namespace ts { es2021: { PromiseConstructor: ["any"], String: ["replaceAll"] - }, - esnext: { - NumberFormat: ["formatToParts"] } }; } diff --git a/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts b/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts index fdff373fee882..081debdb6f688 100644 --- a/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts +++ b/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts @@ -23,6 +23,8 @@ const testAsyncGenerator: AsyncGenerator = null as any; const testAsyncGeneratorFunction: AsyncGeneratorFunction = null as any; const testAsyncIterable: AsyncIterable = null as any; const testAsyncIterableIterator: AsyncIterableIterator = null as any; +const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); + // es2019 const testArrayFlat = [].flat(); @@ -43,6 +45,3 @@ const testBigInt = BigInt(123); // es2021 const testPromiseAny = Promise.any([]); const testStringReplaceAll = "".replaceAll(); - -// esnext -const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); From e818e38f0f5cd5aa83196508334da745595fc56b Mon Sep 17 00:00:00 2001 From: Scharkee Date: Sat, 15 May 2021 22:47:10 +0300 Subject: [PATCH 3/6] Accept baselines --- .../baselines/reference/bigintWithLib.symbols | 8 ++-- ...angeYourTargetLibraryES2016Plus.errors.txt | 39 +++++++++-------- ...NeedToChangeYourTargetLibraryES2016Plus.js | 8 ++-- ...oChangeYourTargetLibraryES2016Plus.symbols | 42 +++++++++---------- ...dToChangeYourTargetLibraryES2016Plus.types | 24 +++++------ 5 files changed, 59 insertions(+), 62 deletions(-) diff --git a/tests/baselines/reference/bigintWithLib.symbols b/tests/baselines/reference/bigintWithLib.symbols index f8f7c6bb8812d..c197f9e156794 100644 --- a/tests/baselines/reference/bigintWithLib.symbols +++ b/tests/baselines/reference/bigintWithLib.symbols @@ -241,16 +241,16 @@ let z = 12n; // should emit type bigint in declaration file // Test Intl methods with new parameter type new Intl.NumberFormat("fr").format(3000n); >new Intl.NumberFormat("fr").format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) ->Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) ->NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) >format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) new Intl.NumberFormat("fr").format(bigintVal); >new Intl.NumberFormat("fr").format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) ->Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) ->NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) >format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) >bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3)) diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt index 05d5e04b51fe3..f373549df379f 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt @@ -16,21 +16,21 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(20,27): err tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(21,35): error TS2583: Cannot find name 'AsyncGeneratorFunction'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(22,26): error TS2583: Cannot find name 'AsyncIterable'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(23,34): error TS2583: Cannot find name 'AsyncIterableIterator'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(26,26): error TS2550: Property 'flat' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(27,29): error TS2550: Property 'flatMap' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(28,49): error TS2550: Property 'fromEntries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(29,32): error TS2550: Property 'trimStart' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(30,30): error TS2550: Property 'trimEnd' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(31,31): error TS2550: Property 'trimLeft' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(32,32): error TS2550: Property 'trimRight' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(33,45): error TS2550: Property 'description' does not exist on type 'symbol'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(36,39): error TS2550: Property 'allSettled' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(37,31): error TS2550: Property 'matchAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(38,47): error TS2550: Property 'matchAll' does not exist on type 'SymbolConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(39,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(42,32): error TS2550: Property 'any' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(43,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. -tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(46,70): error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(24,70): error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(28,26): error TS2550: Property 'flat' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(29,29): error TS2550: Property 'flatMap' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(30,49): error TS2550: Property 'fromEntries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(31,32): error TS2550: Property 'trimStart' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(32,30): error TS2550: Property 'trimEnd' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(33,31): error TS2550: Property 'trimLeft' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(34,32): error TS2550: Property 'trimRight' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(35,45): error TS2550: Property 'description' does not exist on type 'symbol'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(38,39): error TS2550: Property 'allSettled' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(39,31): error TS2550: Property 'matchAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(40,47): error TS2550: Property 'matchAll' does not exist on type 'SymbolConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(41,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,32): error TS2550: Property 'any' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. +tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(45,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. ==== tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts (33 errors) ==== @@ -93,6 +93,10 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(46,70): err const testAsyncIterableIterator: AsyncIterableIterator = null as any; ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2583: Cannot find name 'AsyncIterableIterator'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. + const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); + ~~~~~~~~~~~~~ +!!! error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. + // es2019 const testArrayFlat = [].flat(); @@ -141,9 +145,4 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(46,70): err const testStringReplaceAll = "".replaceAll(); ~~~~~~~~~~ !!! error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. - - // esnext - const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); - ~~~~~~~~~~~~~ -!!! error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. \ No newline at end of file diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js index 0a4f15227b782..baa35774a37db 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js @@ -22,6 +22,8 @@ const testAsyncGenerator: AsyncGenerator = null as any; const testAsyncGeneratorFunction: AsyncGeneratorFunction = null as any; const testAsyncIterable: AsyncIterable = null as any; const testAsyncIterableIterator: AsyncIterableIterator = null as any; +const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); + // es2019 const testArrayFlat = [].flat(); @@ -42,9 +44,6 @@ const testBigInt = BigInt(123); // es2021 const testPromiseAny = Promise.any([]); const testStringReplaceAll = "".replaceAll(); - -// esnext -const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); //// [doYouNeedToChangeYourTargetLibraryES2016Plus.js] @@ -69,6 +68,7 @@ var testAsyncGenerator = null; var testAsyncGeneratorFunction = null; var testAsyncIterable = null; var testAsyncIterableIterator = null; +var testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); // es2019 var testArrayFlat = [].flat(); var testArrayFlatMap = [].flatMap(); @@ -86,5 +86,3 @@ var testBigInt = BigInt(123); // es2021 var testPromiseAny = Promise.any([]); var testStringReplaceAll = "".replaceAll(); -// esnext -var testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols index 060c494e30149..3d161e8ee78ff 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols @@ -69,60 +69,60 @@ const testAsyncIterable: AsyncIterable = null as any; const testAsyncIterableIterator: AsyncIterableIterator = null as any; >testAsyncIterableIterator : Symbol(testAsyncIterableIterator, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 22, 5)) +const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); +>testNumberFormatFormatToParts : Symbol(testNumberFormatFormatToParts, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 23, 5)) +>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --)) +>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // es2019 const testArrayFlat = [].flat(); ->testArrayFlat : Symbol(testArrayFlat, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 25, 5)) +>testArrayFlat : Symbol(testArrayFlat, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 27, 5)) const testArrayFlatMap = [].flatMap(); ->testArrayFlatMap : Symbol(testArrayFlatMap, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 26, 5)) +>testArrayFlatMap : Symbol(testArrayFlatMap, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 28, 5)) const testObjectConstructorFromEntries = Object.fromEntries({}); ->testObjectConstructorFromEntries : Symbol(testObjectConstructorFromEntries, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 27, 5)) +>testObjectConstructorFromEntries : Symbol(testObjectConstructorFromEntries, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 29, 5)) >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) const testStringTrimStart = "".trimStart(); ->testStringTrimStart : Symbol(testStringTrimStart, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 28, 5)) +>testStringTrimStart : Symbol(testStringTrimStart, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 30, 5)) const testStringTrimEnd = "".trimEnd(); ->testStringTrimEnd : Symbol(testStringTrimEnd, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 29, 5)) +>testStringTrimEnd : Symbol(testStringTrimEnd, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 31, 5)) const testStringTrimLeft = "".trimLeft(); ->testStringTrimLeft : Symbol(testStringTrimLeft, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 30, 5)) +>testStringTrimLeft : Symbol(testStringTrimLeft, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 32, 5)) const testStringTrimRight = "".trimRight(); ->testStringTrimRight : Symbol(testStringTrimRight, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 31, 5)) +>testStringTrimRight : Symbol(testStringTrimRight, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 33, 5)) const testSymbolDescription = Symbol("foo").description; ->testSymbolDescription : Symbol(testSymbolDescription, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 32, 5)) +>testSymbolDescription : Symbol(testSymbolDescription, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 34, 5)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) // es2020 const testPromiseAllSettled = Promise.allSettled([]); ->testPromiseAllSettled : Symbol(testPromiseAllSettled, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 35, 5)) +>testPromiseAllSettled : Symbol(testPromiseAllSettled, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 37, 5)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) const testStringMatchAll = "".matchAll(); ->testStringMatchAll : Symbol(testStringMatchAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 36, 5)) +>testStringMatchAll : Symbol(testStringMatchAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 38, 5)) const testRegExpMatchAll = /matchAll/g[Symbol.matchAll]("matchAll"); ->testRegExpMatchAll : Symbol(testRegExpMatchAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 37, 5)) +>testRegExpMatchAll : Symbol(testRegExpMatchAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 39, 5)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) const testBigInt = BigInt(123); ->testBigInt : Symbol(testBigInt, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 38, 5)) +>testBigInt : Symbol(testBigInt, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 40, 5)) // es2021 const testPromiseAny = Promise.any([]); ->testPromiseAny : Symbol(testPromiseAny, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 41, 5)) +>testPromiseAny : Symbol(testPromiseAny, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 43, 5)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) const testStringReplaceAll = "".replaceAll(); ->testStringReplaceAll : Symbol(testStringReplaceAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 42, 5)) - -// esnext -const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); ->testNumberFormatFormatToParts : Symbol(testNumberFormatFormatToParts, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 45, 5)) ->Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --)) ->NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>testStringReplaceAll : Symbol(testStringReplaceAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 44, 5)) diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types index 95bd9e9fb15b6..d25a0297b9b84 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types @@ -147,6 +147,18 @@ const testAsyncIterableIterator: AsyncIterableIterator = null as any; >null as any : any >null : null +const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); +>testNumberFormatFormatToParts : any +>new Intl.NumberFormat("en-US").formatToParts() : any +>new Intl.NumberFormat("en-US").formatToParts : any +>new Intl.NumberFormat("en-US") : Intl.NumberFormat +>Intl.NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; } +>Intl : typeof Intl +>NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; } +>"en-US" : "en-US" +>formatToParts : any + + // es2019 const testArrayFlat = [].flat(); >testArrayFlat : any @@ -254,15 +266,3 @@ const testStringReplaceAll = "".replaceAll(); >"" : "" >replaceAll : any -// esnext -const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts(); ->testNumberFormatFormatToParts : any ->new Intl.NumberFormat("en-US").formatToParts() : any ->new Intl.NumberFormat("en-US").formatToParts : any ->new Intl.NumberFormat("en-US") : Intl.NumberFormat ->Intl.NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; } ->Intl : typeof Intl ->NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; } ->"en-US" : "en-US" ->formatToParts : any - From 513f7dcdcde37c00bd2c33c400075aaab79f968e Mon Sep 17 00:00:00 2001 From: Scharkee Date: Wed, 7 Jul 2021 16:37:05 +0300 Subject: [PATCH 4/6] Remove esnext.intl.d.ts --- src/compiler/commandLineParser.ts | 2 +- src/lib/esnext.intl.d.ts | 1 - src/lib/libs.json | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 src/lib/esnext.intl.d.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 08215b5bcfe8a..5bd7415391173 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -74,7 +74,7 @@ namespace ts { ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.intl", "es2018.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], ["esnext.string", "lib.es2021.string.d.ts"], ["esnext.promise", "lib.es2021.promise.d.ts"], diff --git a/src/lib/esnext.intl.d.ts b/src/lib/esnext.intl.d.ts deleted file mode 100644 index 2256fc6268832..0000000000000 --- a/src/lib/esnext.intl.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare namespace Intl {} diff --git a/src/lib/libs.json b/src/lib/libs.json index 0eb3d7b657a34..0927733ceedf5 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -51,7 +51,6 @@ "es2021.string", "es2021.promise", "es2021.weakref", - "esnext.intl", // Default libraries "es5.full", "es2015.full", From 9640282ea16def03ac906c22729e2bfd471537f8 Mon Sep 17 00:00:00 2001 From: Scharkee Date: Fri, 9 Jul 2021 11:32:06 +0300 Subject: [PATCH 5/6] Remove esnext.intl and accept baselines --- lib/lib.es2018.intl.d.ts | 11 +++++++ lib/lib.esnext.d.ts | 1 - lib/lib.esnext.intl.d.ts | 32 ------------------- src/lib/es2018.intl.d.ts | 2 +- src/lib/esnext.d.ts | 1 - .../reference/formatToPartsBigInt.symbols | 20 ++++++------ 6 files changed, 22 insertions(+), 45 deletions(-) delete mode 100644 lib/lib.esnext.intl.d.ts diff --git a/lib/lib.es2018.intl.d.ts b/lib/lib.es2018.intl.d.ts index 0d7961101e1f0..2c3acd56cbc71 100644 --- a/lib/lib.es2018.intl.d.ts +++ b/lib/lib.es2018.intl.d.ts @@ -58,4 +58,15 @@ declare namespace Intl { options?: PluralRulesOptions, ): string[]; }; + + type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; + + interface NumberFormatPart { + type: NumberFormatPartTypes; + value: string; + } + + interface NumberFormat { + formatToParts(number?: number | bigint): NumberFormatPart[]; + } } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index f1a4c7e1404d8..facc6bb83542b 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -19,4 +19,3 @@ and limitations under the License. /// -/// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts deleted file mode 100644 index 175ef85de7e58..0000000000000 --- a/lib/lib.esnext.intl.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/*! ***************************************************************************** -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, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -declare namespace Intl { - type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; - - interface NumberFormatPart { - type: NumberFormatPartTypes; - value: string; - } - - interface NumberFormat { - formatToParts(number?: number | bigint): NumberFormatPart[]; - } -} diff --git a/src/lib/es2018.intl.d.ts b/src/lib/es2018.intl.d.ts index 9f4d473156966..e25624cf91160 100644 --- a/src/lib/es2018.intl.d.ts +++ b/src/lib/es2018.intl.d.ts @@ -47,6 +47,6 @@ declare namespace Intl { } interface NumberFormat { - formatToParts(number?: number): NumberFormatPart[]; + formatToParts(number?: number | bigint): NumberFormatPart[]; } } diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 4a3ac819c1900..f24c0d3b7e06b 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,2 +1 @@ /// -/// diff --git a/tests/baselines/reference/formatToPartsBigInt.symbols b/tests/baselines/reference/formatToPartsBigInt.symbols index f3037bfef10ed..db1b467cf278c 100644 --- a/tests/baselines/reference/formatToPartsBigInt.symbols +++ b/tests/baselines/reference/formatToPartsBigInt.symbols @@ -3,17 +3,17 @@ // Test Intl methods with new parameter type new Intl.NumberFormat("fr").formatToParts(3000n); ->new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --)) ->Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 1 more) ->NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --)) +>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) +>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) new Intl.NumberFormat("fr").formatToParts(BigInt(123)); ->new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --)) ->Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 1 more) ->NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --)) +>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) +>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) +>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) >BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) From 8e5829df8317392a46b9dc68429b3174c185dea3 Mon Sep 17 00:00:00 2001 From: Scharkee Date: Fri, 9 Jul 2021 11:35:16 +0300 Subject: [PATCH 6/6] Revert lib changes --- lib/lib.es2018.intl.d.ts | 11 ----------- lib/lib.esnext.d.ts | 1 + lib/lib.esnext.intl.d.ts | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 lib/lib.esnext.intl.d.ts diff --git a/lib/lib.es2018.intl.d.ts b/lib/lib.es2018.intl.d.ts index 2c3acd56cbc71..0d7961101e1f0 100644 --- a/lib/lib.es2018.intl.d.ts +++ b/lib/lib.es2018.intl.d.ts @@ -58,15 +58,4 @@ declare namespace Intl { options?: PluralRulesOptions, ): string[]; }; - - type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; - - interface NumberFormatPart { - type: NumberFormatPartTypes; - value: string; - } - - interface NumberFormat { - formatToParts(number?: number | bigint): NumberFormatPart[]; - } } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index facc6bb83542b..f1a4c7e1404d8 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -19,3 +19,4 @@ and limitations under the License. /// +/// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts new file mode 100644 index 0000000000000..175ef85de7e58 --- /dev/null +++ b/lib/lib.esnext.intl.d.ts @@ -0,0 +1,32 @@ +/*! ***************************************************************************** +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, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +declare namespace Intl { + type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; + + interface NumberFormatPart { + type: NumberFormatPartTypes; + value: string; + } + + interface NumberFormat { + formatToParts(number?: number | bigint): NumberFormatPart[]; + } +}