From 06bc6c744f12c767186022068d3cb9724a976105 Mon Sep 17 00:00:00 2001 From: DetachHead Date: Sun, 11 Sep 2022 21:16:58 +1000 Subject: [PATCH 1/4] make `RegExpExecArray` always include index 0 --- src/lib/es5.d.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index f4b499cd81691..7739652a072dc 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -916,7 +916,14 @@ interface DateConstructor { declare var Date: DateConstructor; -interface RegExpMatchArray extends Array { +interface BaseRegExpArray extends Array { + /** + * The first match. This will always be present because `null` will be returned if there are no matches. + */ + 0: string; +} + +interface RegExpMatchArray extends BaseRegExpArray { /** * The index of the search at which the result was found. */ @@ -925,13 +932,9 @@ interface RegExpMatchArray extends Array { * A copy of the search string. */ input?: string; - /** - * The first match. This will always be present because `null` will be returned if there are no matches. - */ - 0: string; } -interface RegExpExecArray extends Array { +interface RegExpExecArray extends BaseRegExpArray { /** * The index of the search at which the result was found. */ From 31386c577dcb93aef0eacfbd796bd8fd339fc724 Mon Sep 17 00:00:00 2001 From: DetachHead Date: Sun, 11 Sep 2022 21:54:30 +1000 Subject: [PATCH 2/4] update baseline --- ...tructuringParameterDeclaration4.errors.txt | 2 +- .../reference/destructuringTuple.errors.txt | 4 ++-- .../duplicateNumericIndexers.errors.txt | 2 +- .../firstMatchRegExpMatchArray.symbols | 2 +- ...ithAsClauseAndLateBoundProperty.errors.txt | 2 +- ...wExceptionVariableInCatchClause.errors.txt | 2 +- .../narrowFromAnyWithInstanceof.errors.txt | 2 +- .../narrowFromAnyWithTypePredicate.errors.txt | 2 +- .../narrowingWithNonNullExpression.symbols | 6 +++--- ...gularExpressionDivideAmbiguity1.errors.txt | 2 +- ...gularExpressionDivideAmbiguity2.errors.txt | 2 +- .../reference/parserS7.2_A1.5_T2.errors.txt | 4 ++-- .../reference/parserS7.3_A1.1_T2.errors.txt | 2 +- .../reference/parserS7.6_A4.2_T1.errors.txt | 20 +++++++++---------- .../reference/parserUnicode1.errors.txt | 4 ++-- .../baselines/reference/parserharness.symbols | 6 +++--- .../reference/promisePermutations.errors.txt | 2 +- .../reference/promisePermutations2.errors.txt | 2 +- .../reference/promisePermutations3.errors.txt | 4 ++-- .../reference/redefineArray.errors.txt | 2 +- .../reference/scannerS7.2_A1.5_T2.errors.txt | 4 ++-- .../reference/scannerS7.3_A1.1_T2.errors.txt | 2 +- .../reference/scannerS7.6_A4.2_T1.errors.txt | 20 +++++++++---------- .../reference/useRegexpGroups.symbols | 1 + 24 files changed, 51 insertions(+), 50 deletions(-) diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index bb7aff5eb0fc0..435e733888af0 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -!!! related TS2728 /.ts/lib.es5.d.ts:1490:13: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1493:13: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '[[any]]'. diff --git a/tests/baselines/reference/destructuringTuple.errors.txt b/tests/baselines/reference/destructuringTuple.errors.txt index e8548783cafc4..10122a2ff87c8 100644 --- a/tests/baselines/reference/destructuringTuple.errors.txt +++ b/tests/baselines/reference/destructuringTuple.errors.txt @@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat !!! error TS2769: Overload 2 of 3, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error. !!! error TS2769: Type 'never[]' is not assignable to type '[]'. !!! error TS2769: Target allows only 0 element(s) but source may have more. -!!! related TS6502 /.ts/lib.es5.d.ts:1455:24: The expected type comes from the return type of this signature. -!!! related TS6502 /.ts/lib.es5.d.ts:1461:27: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1458:24: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1464:27: The expected type comes from the return type of this signature. ~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(...items: ConcatArray[]): never[]', gave the following error. diff --git a/tests/baselines/reference/duplicateNumericIndexers.errors.txt b/tests/baselines/reference/duplicateNumericIndexers.errors.txt index b149e6f586d06..9a5659cc9bfae 100644 --- a/tests/baselines/reference/duplicateNumericIndexers.errors.txt +++ b/tests/baselines/reference/duplicateNumericIndexers.errors.txt @@ -11,7 +11,7 @@ tests/cases/conformance/types/members/duplicateNumericIndexers.ts(25,5): error T tests/cases/conformance/types/members/duplicateNumericIndexers.ts(29,5): error TS2374: Duplicate index signature for type 'number'. tests/cases/conformance/types/members/duplicateNumericIndexers.ts(30,5): error TS2374: Duplicate index signature for type 'number'. lib.es5.d.ts(517,5): error TS2374: Duplicate index signature for type 'number'. -lib.es5.d.ts(1476,5): error TS2374: Duplicate index signature for type 'number'. +lib.es5.d.ts(1479,5): error TS2374: Duplicate index signature for type 'number'. ==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ==== diff --git a/tests/baselines/reference/firstMatchRegExpMatchArray.symbols b/tests/baselines/reference/firstMatchRegExpMatchArray.symbols index 39569bc41acf2..558df93a2adc2 100644 --- a/tests/baselines/reference/firstMatchRegExpMatchArray.symbols +++ b/tests/baselines/reference/firstMatchRegExpMatchArray.symbols @@ -10,7 +10,7 @@ if (match !== null) { const foo: string = match[0] >foo : Symbol(foo, Decl(firstMatchRegExpMatchArray.ts, 3, 9)) >match : Symbol(match, Decl(firstMatchRegExpMatchArray.ts, 0, 5)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) const bar: string = match[1] >bar : Symbol(bar, Decl(firstMatchRegExpMatchArray.ts, 4, 9)) diff --git a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt index 5fb49e0dd99b6..f9a462166d1ab 100644 --- a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt +++ b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt @@ -7,5 +7,5 @@ tests/cases/compiler/mappedTypeWithAsClauseAndLateBoundProperty.ts(3,1): error T tgt2 = src2; // Should error ~~~~ !!! error TS2741: Property 'length' is missing in type '{ [x: number]: number; toString: () => string; toLocaleString: () => string; pop: () => number; push: (...items: number[]) => number; concat: { (...items: ConcatArray[]): number[]; (...items: (number | ConcatArray)[]): number[]; }; join: (separator?: string) => string; reverse: () => number[]; shift: () => number; slice: (start?: number, end?: number) => number[]; sort: (compareFn?: (a: number, b: number) => number) => number[]; splice: { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }; unshift: (...items: number[]) => number; indexOf: (searchElement: number, fromIndex?: number) => number; lastIndexOf: (searchElement: number, fromIndex?: number) => number; every: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; }; some: (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean; forEach: (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void; map: (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]; filter: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; }; reduce: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; reduceRight: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; find: { (predicate: (this: void, value: number, index: number, obj: number[]) => value is S, thisArg?: any): S; (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any): number; }; findIndex: (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any) => number; fill: (value: number, start?: number, end?: number) => number[]; copyWithin: (target: number, start: number, end?: number) => number[]; entries: () => IterableIterator<[number, number]>; keys: () => IterableIterator; values: () => IterableIterator; includes: (searchElement: number, fromIndex?: number) => boolean; flatMap: (callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]; flat: (this: A, depth?: D) => FlatArray[]; [iterator]: () => IterableIterator; [unscopables]: () => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }' but required in type 'number[]'. -!!! related TS2728 /.ts/lib.es5.d.ts:1299:5: 'length' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1302:5: 'length' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt index 3a07bb2f5d9b6..0dca67020bedc 100644 --- a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt @@ -24,7 +24,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17) err.massage; // ERROR: Property 'massage' does not exist on type 'Error' ~~~~~~~ !!! error TS2551: Property 'massage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. } else { diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt index 2206d1c9b214b..5cc74edc6d930 100644 --- a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt @@ -22,7 +22,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. } if (x instanceof Date) { diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt index 109738a3f4bc8..dacad99535ace 100644 --- a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. } if (isDate(x)) { diff --git a/tests/baselines/reference/narrowingWithNonNullExpression.symbols b/tests/baselines/reference/narrowingWithNonNullExpression.symbols index b60abdddbe61f..5100b784f2797 100644 --- a/tests/baselines/reference/narrowingWithNonNullExpression.symbols +++ b/tests/baselines/reference/narrowingWithNonNullExpression.symbols @@ -7,11 +7,11 @@ const m = ''.match(''); m! && m[0]; >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) m?.[0]! && m[0]; >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt index 252a08e5c3874..f14b0ccbe41a7 100644 --- a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt @@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre /notregexp/a.foo(); ~~~~~~~~~ !!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'? -!!! related TS2728 /.ts/lib.es5.d.ts:1045:13: 'RegExp' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1048:13: 'RegExp' is declared here. ~ !!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt index 3eb2b9824267c..e0f32f5a497f1 100644 --- a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt @@ -6,6 +6,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre (1) /notregexp/a.foo(); ~~~~~~~~~ !!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'? -!!! related TS2728 /.ts/lib.es5.d.ts:1045:13: 'RegExp' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1048:13: 'RegExp' is declared here. ~ !!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt index d89e7dbdbf68f..40996a0ba0425 100644 --- a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt index 1b259eccc99b7..a80fcdc4d51a9 100644 --- a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt index 3e7acb4d3f164..1046e88309abf 100644 --- a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts(142,3): error T $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/parserUnicode1.errors.txt b/tests/baselines/reference/parserUnicode1.errors.txt index d2f7148f6f271..335c136388c61 100644 --- a/tests/baselines/reference/parserUnicode1.errors.txt +++ b/tests/baselines/reference/parserUnicode1.errors.txt @@ -11,13 +11,13 @@ tests/cases/conformance/parser/ecmascript5/parserUnicode1.ts(10,5): error TS2552 $ERROR('#6.1: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } } catch (e) { $ERROR('#6.2: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserharness.symbols b/tests/baselines/reference/parserharness.symbols index 62604cadf5a19..8ca32f300e875 100644 --- a/tests/baselines/reference/parserharness.symbols +++ b/tests/baselines/reference/parserharness.symbols @@ -3809,7 +3809,7 @@ module Harness { >path.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) >path : Symbol(path, Decl(parserharness.ts, 1285, 36)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) var code = readFile(path); >code : Symbol(code, Decl(parserharness.ts, 1288, 15)) @@ -3947,7 +3947,7 @@ module Harness { >lastUnit : Symbol(lastUnit, Decl(parserharness.ts, 1326, 15)) >name : Symbol(TestCaseParser.TestUnitData.name, Decl(parserharness.ts, 1422, 28)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) var dependencies = units.slice(0, units.length - 1); >dependencies : Symbol(dependencies, Decl(parserharness.ts, 1329, 15)) @@ -5700,7 +5700,7 @@ module Harness { >path.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) >path : Symbol(path, Decl(parserharness.ts, 1869, 38)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) >callback : Symbol(callback, Decl(parserharness.ts, 1869, 51)) } diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index c9862aec4ec6c..069760228de90 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -447,7 +447,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload m !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations.ts:5:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 17ac4d4aa3c72..570f1911c9e4c 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -351,7 +351,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 835c3fcb71bcf..ad198fb310013 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -398,7 +398,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations3.ts:7:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -445,5 +445,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index 0af9576082efa..cc717eb669634 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -5,4 +5,4 @@ tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is Array = function (n:number, s:string) {return n;}; ~~~~~ !!! error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. -!!! related TS2728 /.ts/lib.es5.d.ts:1486:5: 'isArray' is declared here. \ No newline at end of file +!!! related TS2728 /.ts/lib.es5.d.ts:1489:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt index 535cc4b2f970f..24ea8ea6da466 100644 --- a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt index 40c4e573c779d..c1f1822ccc568 100644 --- a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.3_A1.1_T2.ts(17,3): error $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt index ba258b4f255c3..74b70c26ed781 100644 --- a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts(142,3): error $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/useRegexpGroups.symbols b/tests/baselines/reference/useRegexpGroups.symbols index ebfa86f6c2cee..623ddea6ba245 100644 --- a/tests/baselines/reference/useRegexpGroups.symbols +++ b/tests/baselines/reference/useRegexpGroups.symbols @@ -11,6 +11,7 @@ let result = re.exec("2015-01-02"); let date = result[0]; >date : Symbol(date, Decl(useRegexpGroups.ts, 3, 3)) >result : Symbol(result, Decl(useRegexpGroups.ts, 1, 3)) +>0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) let year1 = result.groups.year; >year1 : Symbol(year1, Decl(useRegexpGroups.ts, 5, 3)) From e4462942d9767910db6895fdc5f6526367788729 Mon Sep 17 00:00:00 2001 From: DetachHead Date: Tue, 13 Sep 2022 21:01:15 +1000 Subject: [PATCH 3/4] remove `BaseRegExpArray` interface --- src/lib/es5.d.ts | 19 +++++++++--------- ...tructuringParameterDeclaration4.errors.txt | 2 +- .../reference/destructuringTuple.errors.txt | 4 ++-- .../duplicateNumericIndexers.errors.txt | 2 +- .../firstMatchRegExpMatchArray.symbols | 2 +- ...ithAsClauseAndLateBoundProperty.errors.txt | 2 +- ...wExceptionVariableInCatchClause.errors.txt | 2 +- .../narrowFromAnyWithInstanceof.errors.txt | 2 +- .../narrowFromAnyWithTypePredicate.errors.txt | 2 +- .../narrowingWithNonNullExpression.symbols | 6 +++--- ...gularExpressionDivideAmbiguity1.errors.txt | 2 +- ...gularExpressionDivideAmbiguity2.errors.txt | 2 +- .../reference/parserS7.2_A1.5_T2.errors.txt | 4 ++-- .../reference/parserS7.3_A1.1_T2.errors.txt | 2 +- .../reference/parserS7.6_A4.2_T1.errors.txt | 20 +++++++++---------- .../reference/parserUnicode1.errors.txt | 4 ++-- .../baselines/reference/parserharness.symbols | 6 +++--- .../reference/promisePermutations.errors.txt | 2 +- .../reference/promisePermutations2.errors.txt | 2 +- .../reference/promisePermutations3.errors.txt | 4 ++-- .../reference/redefineArray.errors.txt | 2 +- .../reference/scannerS7.2_A1.5_T2.errors.txt | 4 ++-- .../reference/scannerS7.3_A1.1_T2.errors.txt | 2 +- .../reference/scannerS7.6_A4.2_T1.errors.txt | 20 +++++++++---------- .../reference/useRegexpGroups.symbols | 2 +- 25 files changed, 61 insertions(+), 60 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 7739652a072dc..36c4e4fff24b0 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -916,14 +916,7 @@ interface DateConstructor { declare var Date: DateConstructor; -interface BaseRegExpArray extends Array { - /** - * The first match. This will always be present because `null` will be returned if there are no matches. - */ - 0: string; -} - -interface RegExpMatchArray extends BaseRegExpArray { +interface RegExpMatchArray extends Array { /** * The index of the search at which the result was found. */ @@ -932,9 +925,13 @@ interface RegExpMatchArray extends BaseRegExpArray { * A copy of the search string. */ input?: string; + /** + * The first match. This will always be present because `null` will be returned if there are no matches. + */ + 0: string; } -interface RegExpExecArray extends BaseRegExpArray { +interface RegExpExecArray extends Array { /** * The index of the search at which the result was found. */ @@ -943,6 +940,10 @@ interface RegExpExecArray extends BaseRegExpArray { * A copy of the search string. */ input: string; + /** + * The first match. This will always be present because `null` will be returned if there are no matches. + */ + 0: string; } interface RegExp { diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 435e733888af0..3f893a65b82af 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -!!! related TS2728 /.ts/lib.es5.d.ts:1493:13: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1494:13: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '[[any]]'. diff --git a/tests/baselines/reference/destructuringTuple.errors.txt b/tests/baselines/reference/destructuringTuple.errors.txt index 10122a2ff87c8..7a6ff666f6271 100644 --- a/tests/baselines/reference/destructuringTuple.errors.txt +++ b/tests/baselines/reference/destructuringTuple.errors.txt @@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat !!! error TS2769: Overload 2 of 3, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error. !!! error TS2769: Type 'never[]' is not assignable to type '[]'. !!! error TS2769: Target allows only 0 element(s) but source may have more. -!!! related TS6502 /.ts/lib.es5.d.ts:1458:24: The expected type comes from the return type of this signature. -!!! related TS6502 /.ts/lib.es5.d.ts:1464:27: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1459:24: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1465:27: The expected type comes from the return type of this signature. ~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(...items: ConcatArray[]): never[]', gave the following error. diff --git a/tests/baselines/reference/duplicateNumericIndexers.errors.txt b/tests/baselines/reference/duplicateNumericIndexers.errors.txt index 9a5659cc9bfae..b54aa648ebc46 100644 --- a/tests/baselines/reference/duplicateNumericIndexers.errors.txt +++ b/tests/baselines/reference/duplicateNumericIndexers.errors.txt @@ -11,7 +11,7 @@ tests/cases/conformance/types/members/duplicateNumericIndexers.ts(25,5): error T tests/cases/conformance/types/members/duplicateNumericIndexers.ts(29,5): error TS2374: Duplicate index signature for type 'number'. tests/cases/conformance/types/members/duplicateNumericIndexers.ts(30,5): error TS2374: Duplicate index signature for type 'number'. lib.es5.d.ts(517,5): error TS2374: Duplicate index signature for type 'number'. -lib.es5.d.ts(1479,5): error TS2374: Duplicate index signature for type 'number'. +lib.es5.d.ts(1480,5): error TS2374: Duplicate index signature for type 'number'. ==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ==== diff --git a/tests/baselines/reference/firstMatchRegExpMatchArray.symbols b/tests/baselines/reference/firstMatchRegExpMatchArray.symbols index 558df93a2adc2..39569bc41acf2 100644 --- a/tests/baselines/reference/firstMatchRegExpMatchArray.symbols +++ b/tests/baselines/reference/firstMatchRegExpMatchArray.symbols @@ -10,7 +10,7 @@ if (match !== null) { const foo: string = match[0] >foo : Symbol(foo, Decl(firstMatchRegExpMatchArray.ts, 3, 9)) >match : Symbol(match, Decl(firstMatchRegExpMatchArray.ts, 0, 5)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) const bar: string = match[1] >bar : Symbol(bar, Decl(firstMatchRegExpMatchArray.ts, 4, 9)) diff --git a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt index f9a462166d1ab..4523d9a9ade24 100644 --- a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt +++ b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt @@ -7,5 +7,5 @@ tests/cases/compiler/mappedTypeWithAsClauseAndLateBoundProperty.ts(3,1): error T tgt2 = src2; // Should error ~~~~ !!! error TS2741: Property 'length' is missing in type '{ [x: number]: number; toString: () => string; toLocaleString: () => string; pop: () => number; push: (...items: number[]) => number; concat: { (...items: ConcatArray[]): number[]; (...items: (number | ConcatArray)[]): number[]; }; join: (separator?: string) => string; reverse: () => number[]; shift: () => number; slice: (start?: number, end?: number) => number[]; sort: (compareFn?: (a: number, b: number) => number) => number[]; splice: { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }; unshift: (...items: number[]) => number; indexOf: (searchElement: number, fromIndex?: number) => number; lastIndexOf: (searchElement: number, fromIndex?: number) => number; every: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; }; some: (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean; forEach: (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void; map: (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]; filter: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; }; reduce: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; reduceRight: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; find: { (predicate: (this: void, value: number, index: number, obj: number[]) => value is S, thisArg?: any): S; (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any): number; }; findIndex: (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any) => number; fill: (value: number, start?: number, end?: number) => number[]; copyWithin: (target: number, start: number, end?: number) => number[]; entries: () => IterableIterator<[number, number]>; keys: () => IterableIterator; values: () => IterableIterator; includes: (searchElement: number, fromIndex?: number) => boolean; flatMap: (callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]; flat: (this: A, depth?: D) => FlatArray[]; [iterator]: () => IterableIterator; [unscopables]: () => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }' but required in type 'number[]'. -!!! related TS2728 /.ts/lib.es5.d.ts:1302:5: 'length' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1303:5: 'length' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt index 0dca67020bedc..16e36f119e8fb 100644 --- a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt @@ -24,7 +24,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17) err.massage; // ERROR: Property 'massage' does not exist on type 'Error' ~~~~~~~ !!! error TS2551: Property 'massage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1053:5: 'message' is declared here. } else { diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt index 5cc74edc6d930..f0707d7fbc485 100644 --- a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt @@ -22,7 +22,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1053:5: 'message' is declared here. } if (x instanceof Date) { diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt index dacad99535ace..a104e9e4a334c 100644 --- a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? -!!! related TS2728 /.ts/lib.es5.d.ts:1052:5: 'message' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1053:5: 'message' is declared here. } if (isDate(x)) { diff --git a/tests/baselines/reference/narrowingWithNonNullExpression.symbols b/tests/baselines/reference/narrowingWithNonNullExpression.symbols index 5100b784f2797..b60abdddbe61f 100644 --- a/tests/baselines/reference/narrowingWithNonNullExpression.symbols +++ b/tests/baselines/reference/narrowingWithNonNullExpression.symbols @@ -7,11 +7,11 @@ const m = ''.match(''); m! && m[0]; >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) m?.[0]! && m[0]; >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) >m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt index f14b0ccbe41a7..926040527e503 100644 --- a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt @@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre /notregexp/a.foo(); ~~~~~~~~~ !!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'? -!!! related TS2728 /.ts/lib.es5.d.ts:1048:13: 'RegExp' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1049:13: 'RegExp' is declared here. ~ !!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt index e0f32f5a497f1..116f7dcc790a8 100644 --- a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt @@ -6,6 +6,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre (1) /notregexp/a.foo(); ~~~~~~~~~ !!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'? -!!! related TS2728 /.ts/lib.es5.d.ts:1048:13: 'RegExp' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1049:13: 'RegExp' is declared here. ~ !!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt index 40996a0ba0425..d65f50bdb7203 100644 --- a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt index a80fcdc4d51a9..77ff67746e96a 100644 --- a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt index 1046e88309abf..f1703c9f7ef9c 100644 --- a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts(142,3): error T $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/parserUnicode1.errors.txt b/tests/baselines/reference/parserUnicode1.errors.txt index 335c136388c61..1cc793e66da1e 100644 --- a/tests/baselines/reference/parserUnicode1.errors.txt +++ b/tests/baselines/reference/parserUnicode1.errors.txt @@ -11,13 +11,13 @@ tests/cases/conformance/parser/ecmascript5/parserUnicode1.ts(10,5): error TS2552 $ERROR('#6.1: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } } catch (e) { $ERROR('#6.2: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserharness.symbols b/tests/baselines/reference/parserharness.symbols index 8ca32f300e875..62604cadf5a19 100644 --- a/tests/baselines/reference/parserharness.symbols +++ b/tests/baselines/reference/parserharness.symbols @@ -3809,7 +3809,7 @@ module Harness { >path.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) >path : Symbol(path, Decl(parserharness.ts, 1285, 36)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) var code = readFile(path); >code : Symbol(code, Decl(parserharness.ts, 1288, 15)) @@ -3947,7 +3947,7 @@ module Harness { >lastUnit : Symbol(lastUnit, Decl(parserharness.ts, 1326, 15)) >name : Symbol(TestCaseParser.TestUnitData.name, Decl(parserharness.ts, 1422, 28)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) var dependencies = units.slice(0, units.length - 1); >dependencies : Symbol(dependencies, Decl(parserharness.ts, 1329, 15)) @@ -5700,7 +5700,7 @@ module Harness { >path.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) >path : Symbol(path, Decl(parserharness.ts, 1869, 38)) >match : Symbol(String.match, Decl(lib.es5.d.ts, --, --)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --)) >callback : Symbol(callback, Decl(parserharness.ts, 1869, 51)) } diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 069760228de90..8b90ae101d0ea 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -447,7 +447,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload m !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1539:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations.ts:5:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 570f1911c9e4c..a22088fb61714 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -351,7 +351,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1539:5: 'catch' is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index ad198fb310013..bfe5ba9d71c97 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -398,7 +398,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1539:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations3.ts:7:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -445,5 +445,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1538:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1539:5: 'catch' is declared here. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index cc717eb669634..97a7fb2124ea6 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -5,4 +5,4 @@ tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is Array = function (n:number, s:string) {return n;}; ~~~~~ !!! error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. -!!! related TS2728 /.ts/lib.es5.d.ts:1489:5: 'isArray' is declared here. \ No newline at end of file +!!! related TS2728 /.ts/lib.es5.d.ts:1490:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt index 24ea8ea6da466..d5c5b74d8b6a9 100644 --- a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt index c1f1822ccc568..0a69936f51505 100644 --- a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.3_A1.1_T2.ts(17,3): error $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt index 74b70c26ed781..d74d50f222102 100644 --- a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts(142,3): error $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:1062:13: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1063:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/useRegexpGroups.symbols b/tests/baselines/reference/useRegexpGroups.symbols index 623ddea6ba245..62347a09a965c 100644 --- a/tests/baselines/reference/useRegexpGroups.symbols +++ b/tests/baselines/reference/useRegexpGroups.symbols @@ -11,7 +11,7 @@ let result = re.exec("2015-01-02"); let date = result[0]; >date : Symbol(date, Decl(useRegexpGroups.ts, 3, 3)) >result : Symbol(result, Decl(useRegexpGroups.ts, 1, 3)) ->0 : Symbol(BaseRegExpArray[0], Decl(lib.es5.d.ts, --, --)) +>0 : Symbol(RegExpExecArray[0], Decl(lib.es5.d.ts, --, --)) let year1 = result.groups.year; >year1 : Symbol(year1, Decl(useRegexpGroups.ts, 5, 3)) From 1300bb510ed40b35be81154ef4187d8f1b386125 Mon Sep 17 00:00:00 2001 From: DetachHead Date: Thu, 15 Sep 2022 22:02:38 +1000 Subject: [PATCH 4/4] add test --- ...ndMatchTypeUsages(strict=false).errors.txt | 28 +++++ ...expExecAndMatchTypeUsages(strict=false).js | 50 ++++++++ ...ecAndMatchTypeUsages(strict=false).symbols | 96 +++++++++++++++ ...ExecAndMatchTypeUsages(strict=false).types | 113 ++++++++++++++++++ ...AndMatchTypeUsages(strict=true).errors.txt | 50 ++++++++ ...gexpExecAndMatchTypeUsages(strict=true).js | 50 ++++++++ ...xecAndMatchTypeUsages(strict=true).symbols | 96 +++++++++++++++ ...pExecAndMatchTypeUsages(strict=true).types | 113 ++++++++++++++++++ .../compiler/regexpExecAndMatchTypeUsages.ts | 27 +++++ 9 files changed, 623 insertions(+) create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).errors.txt create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).js create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).symbols create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).types create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).errors.txt create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).js create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).symbols create mode 100644 tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).types create mode 100644 tests/cases/compiler/regexpExecAndMatchTypeUsages.ts diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).errors.txt b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).errors.txt new file mode 100644 index 0000000000000..fc2f834c04cda --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).errors.txt @@ -0,0 +1,28 @@ +error TS5052: Option 'exactOptionalPropertyTypes' cannot be specified without specifying option 'strictNullChecks'. + + +!!! error TS5052: Option 'exactOptionalPropertyTypes' cannot be specified without specifying option 'strictNullChecks'. +==== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts (0 errors) ==== + export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).js b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).js new file mode 100644 index 0000000000000..3ede67faf484b --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).js @@ -0,0 +1,50 @@ +//// [regexpExecAndMatchTypeUsages.ts] +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult + } +} + + +//// [regexpExecAndMatchTypeUsages.js] +"use strict"; +exports.__esModule = true; +exports.foo = void 0; +function foo(matchResult, execResult) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult; + } +} +exports.foo = foo; diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).symbols b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).symbols new file mode 100644 index 0000000000000..d522b66d9b380 --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).symbols @@ -0,0 +1,96 @@ +=== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts === +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { +>foo : Symbol(foo, Decl(regexpExecAndMatchTypeUsages.ts, 0, 0)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>RegExpExecArray : Symbol(RegExpExecArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>RegExpExecArray : Symbol(RegExpExecArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --)) + + matchResult[0].length; +>matchResult[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>0 : Symbol(RegExpExecArray[0], Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult[999].length; +>matchResult[999].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.index + 0; +>matchResult.index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) + + matchResult.input.length; +>matchResult.input.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult.input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.groups["someVariable"].length; +>matchResult.groups["someVariable"].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.groups = undefined; +>matchResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>undefined : Symbol(undefined) + + execResult[0].length; +>execResult[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>0 : Symbol(RegExpExecArray[0], Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult[999].length; +>execResult[999].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.index + 0; +>execResult.index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) + + execResult.input.length; +>execResult.input.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult.input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.groups["someVariable"].length; +>execResult.groups["someVariable"].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.groups = undefined; +>execResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>undefined : Symbol(undefined) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + matchResult = execResult; +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) + } + else { + execResult = matchResult +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) + } +} + diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).types b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).types new file mode 100644 index 0000000000000..afbb86d0e579e --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=false).types @@ -0,0 +1,113 @@ +=== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts === +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { +>foo : (matchResult: RegExpExecArray, execResult: RegExpExecArray) => void +>matchResult : RegExpExecArray +>execResult : RegExpExecArray + + matchResult[0].length; +>matchResult[0].length : number +>matchResult[0] : string +>matchResult : RegExpExecArray +>0 : 0 +>length : number + + matchResult[999].length; +>matchResult[999].length : number +>matchResult[999] : string +>matchResult : RegExpExecArray +>999 : 999 +>length : number + + matchResult.index + 0; +>matchResult.index + 0 : number +>matchResult.index : number +>matchResult : RegExpExecArray +>index : number +>0 : 0 + + matchResult.input.length; +>matchResult.input.length : number +>matchResult.input : string +>matchResult : RegExpExecArray +>input : string +>length : number + + matchResult.groups["someVariable"].length; +>matchResult.groups["someVariable"].length : number +>matchResult.groups["someVariable"] : string +>matchResult.groups : { [key: string]: string; } +>matchResult : RegExpExecArray +>groups : { [key: string]: string; } +>"someVariable" : "someVariable" +>length : number + + matchResult.groups = undefined; +>matchResult.groups = undefined : undefined +>matchResult.groups : { [key: string]: string; } +>matchResult : RegExpExecArray +>groups : { [key: string]: string; } +>undefined : undefined + + execResult[0].length; +>execResult[0].length : number +>execResult[0] : string +>execResult : RegExpExecArray +>0 : 0 +>length : number + + execResult[999].length; +>execResult[999].length : number +>execResult[999] : string +>execResult : RegExpExecArray +>999 : 999 +>length : number + + execResult.index + 0; +>execResult.index + 0 : number +>execResult.index : number +>execResult : RegExpExecArray +>index : number +>0 : 0 + + execResult.input.length; +>execResult.input.length : number +>execResult.input : string +>execResult : RegExpExecArray +>input : string +>length : number + + execResult.groups["someVariable"].length; +>execResult.groups["someVariable"].length : number +>execResult.groups["someVariable"] : string +>execResult.groups : { [key: string]: string; } +>execResult : RegExpExecArray +>groups : { [key: string]: string; } +>"someVariable" : "someVariable" +>length : number + + execResult.groups = undefined; +>execResult.groups = undefined : undefined +>execResult.groups : { [key: string]: string; } +>execResult : RegExpExecArray +>groups : { [key: string]: string; } +>undefined : undefined + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + matchResult = execResult; +>matchResult = execResult : RegExpExecArray +>matchResult : RegExpExecArray +>execResult : RegExpExecArray + } + else { + execResult = matchResult +>execResult = matchResult : RegExpExecArray +>execResult : RegExpExecArray +>matchResult : RegExpExecArray + } +} + diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).errors.txt b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).errors.txt new file mode 100644 index 0000000000000..b5189443524fa --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).errors.txt @@ -0,0 +1,50 @@ +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(3,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(6,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(6,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(7,5): error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(10,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(13,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(13,5): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(14,5): error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target. + + +==== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts (8 errors) ==== + export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { + matchResult[0].length; + matchResult[999].length; + ~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + matchResult.groups = undefined; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target. + + execResult[0].length; + execResult[999].length; + ~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + ~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + execResult.groups = undefined; + ~~~~~~~~~~~~~~~~~ +!!! error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target. + + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).js b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).js new file mode 100644 index 0000000000000..3ede67faf484b --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).js @@ -0,0 +1,50 @@ +//// [regexpExecAndMatchTypeUsages.ts] +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult + } +} + + +//// [regexpExecAndMatchTypeUsages.js] +"use strict"; +exports.__esModule = true; +exports.foo = void 0; +function foo(matchResult, execResult) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult; + } +} +exports.foo = foo; diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).symbols b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).symbols new file mode 100644 index 0000000000000..d522b66d9b380 --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).symbols @@ -0,0 +1,96 @@ +=== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts === +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { +>foo : Symbol(foo, Decl(regexpExecAndMatchTypeUsages.ts, 0, 0)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>RegExpExecArray : Symbol(RegExpExecArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>RegExpExecArray : Symbol(RegExpExecArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --)) + + matchResult[0].length; +>matchResult[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>0 : Symbol(RegExpExecArray[0], Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult[999].length; +>matchResult[999].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.index + 0; +>matchResult.index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) + + matchResult.input.length; +>matchResult.input.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult.input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.groups["someVariable"].length; +>matchResult.groups["someVariable"].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>matchResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + matchResult.groups = undefined; +>matchResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>undefined : Symbol(undefined) + + execResult[0].length; +>execResult[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>0 : Symbol(RegExpExecArray[0], Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult[999].length; +>execResult[999].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.index + 0; +>execResult.index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>index : Symbol(RegExpExecArray.index, Decl(lib.es5.d.ts, --, --)) + + execResult.input.length; +>execResult.input.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult.input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>input : Symbol(RegExpExecArray.input, Decl(lib.es5.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.groups["someVariable"].length; +>execResult.groups["someVariable"].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>execResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + execResult.groups = undefined; +>execResult.groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>groups : Symbol(RegExpExecArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>undefined : Symbol(undefined) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + matchResult = execResult; +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) + } + else { + execResult = matchResult +>execResult : Symbol(execResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 49)) +>matchResult : Symbol(matchResult, Decl(regexpExecAndMatchTypeUsages.ts, 0, 20)) + } +} + diff --git a/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).types b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).types new file mode 100644 index 0000000000000..aa7aa97583931 --- /dev/null +++ b/tests/baselines/reference/regexpExecAndMatchTypeUsages(strict=true).types @@ -0,0 +1,113 @@ +=== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts === +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { +>foo : (matchResult: RegExpExecArray, execResult: RegExpExecArray) => void +>matchResult : RegExpExecArray +>execResult : RegExpExecArray + + matchResult[0].length; +>matchResult[0].length : number +>matchResult[0] : string +>matchResult : RegExpExecArray +>0 : 0 +>length : number + + matchResult[999].length; +>matchResult[999].length : number +>matchResult[999] : string | undefined +>matchResult : RegExpExecArray +>999 : 999 +>length : number + + matchResult.index + 0; +>matchResult.index + 0 : number +>matchResult.index : number +>matchResult : RegExpExecArray +>index : number +>0 : 0 + + matchResult.input.length; +>matchResult.input.length : number +>matchResult.input : string +>matchResult : RegExpExecArray +>input : string +>length : number + + matchResult.groups["someVariable"].length; +>matchResult.groups["someVariable"].length : number +>matchResult.groups["someVariable"] : string | undefined +>matchResult.groups : { [key: string]: string; } | undefined +>matchResult : RegExpExecArray +>groups : { [key: string]: string; } | undefined +>"someVariable" : "someVariable" +>length : number + + matchResult.groups = undefined; +>matchResult.groups = undefined : undefined +>matchResult.groups : { [key: string]: string; } +>matchResult : RegExpExecArray +>groups : { [key: string]: string; } +>undefined : undefined + + execResult[0].length; +>execResult[0].length : number +>execResult[0] : string +>execResult : RegExpExecArray +>0 : 0 +>length : number + + execResult[999].length; +>execResult[999].length : number +>execResult[999] : string | undefined +>execResult : RegExpExecArray +>999 : 999 +>length : number + + execResult.index + 0; +>execResult.index + 0 : number +>execResult.index : number +>execResult : RegExpExecArray +>index : number +>0 : 0 + + execResult.input.length; +>execResult.input.length : number +>execResult.input : string +>execResult : RegExpExecArray +>input : string +>length : number + + execResult.groups["someVariable"].length; +>execResult.groups["someVariable"].length : number +>execResult.groups["someVariable"] : string | undefined +>execResult.groups : { [key: string]: string; } | undefined +>execResult : RegExpExecArray +>groups : { [key: string]: string; } | undefined +>"someVariable" : "someVariable" +>length : number + + execResult.groups = undefined; +>execResult.groups = undefined : undefined +>execResult.groups : { [key: string]: string; } +>execResult : RegExpExecArray +>groups : { [key: string]: string; } +>undefined : undefined + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + matchResult = execResult; +>matchResult = execResult : RegExpExecArray +>matchResult : RegExpExecArray +>execResult : RegExpExecArray + } + else { + execResult = matchResult +>execResult = matchResult : RegExpExecArray +>execResult : RegExpExecArray +>matchResult : RegExpExecArray + } +} + diff --git a/tests/cases/compiler/regexpExecAndMatchTypeUsages.ts b/tests/cases/compiler/regexpExecAndMatchTypeUsages.ts new file mode 100644 index 0000000000000..359e2b2b03c73 --- /dev/null +++ b/tests/cases/compiler/regexpExecAndMatchTypeUsages.ts @@ -0,0 +1,27 @@ +// @strict: true,false +// @noUncheckedIndexedAccess: true +// @exactOptionalPropertyTypes: true +// @lib: es2018 + +export function foo(matchResult: RegExpExecArray, execResult: RegExpExecArray) { + matchResult[0].length; + matchResult[999].length; + matchResult.index + 0; + matchResult.input.length; + matchResult.groups["someVariable"].length; + matchResult.groups = undefined; + + execResult[0].length; + execResult[999].length; + execResult.index + 0; + execResult.input.length; + execResult.groups["someVariable"].length; + execResult.groups = undefined; + + if (Math.random()) { + matchResult = execResult; + } + else { + execResult = matchResult + } +}