mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix first match in RegExpMatchArray being possibly undefined when noUncheckedIndexedAccess is enabled (#49682)
* fix first match in `RegExpMatchArray` being possibly undefined when `noUncheckedIndexedAccess` is enabled * fix tests * add test Co-authored-by: DetachHead <detachhead@users.noreply.github.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
co-authored by
DetachHead
Nathan Shively-Sanders
parent
330e33cdda
commit
3b80ddca21
Vendored
+4
@@ -925,6 +925,10 @@ interface RegExpMatchArray extends Array<string> {
|
||||
* 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<string> {
|
||||
|
||||
@@ -17,8 +17,8 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48
|
||||
indexOf(searchString: string, position?: number): number;
|
||||
lastIndexOf(searchString: string, position?: number): number;
|
||||
localeCompare(that: string): number;
|
||||
match(regexp: string): string[];
|
||||
match(regexp: RegExp): string[];
|
||||
match(regexp: string): RegExpMatchArray;
|
||||
match(regexp: RegExp): RegExpMatchArray;
|
||||
replace(searchValue: string, replaceValue: string): string;
|
||||
replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string;
|
||||
replace(searchValue: RegExp, replaceValue: string): string;
|
||||
@@ -44,11 +44,11 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48
|
||||
var a: String;
|
||||
var b: NotString;
|
||||
|
||||
a = x;
|
||||
a = b;
|
||||
a = x;
|
||||
a = b;
|
||||
|
||||
b = a;
|
||||
b = x;
|
||||
b = a;
|
||||
b = x;
|
||||
|
||||
x = a; // expected error
|
||||
~
|
||||
|
||||
@@ -12,8 +12,8 @@ interface NotString {
|
||||
indexOf(searchString: string, position?: number): number;
|
||||
lastIndexOf(searchString: string, position?: number): number;
|
||||
localeCompare(that: string): number;
|
||||
match(regexp: string): string[];
|
||||
match(regexp: RegExp): string[];
|
||||
match(regexp: string): RegExpMatchArray;
|
||||
match(regexp: RegExp): RegExpMatchArray;
|
||||
replace(searchValue: string, replaceValue: string): string;
|
||||
replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string;
|
||||
replace(searchValue: RegExp, replaceValue: string): string;
|
||||
@@ -39,11 +39,11 @@ var x = '';
|
||||
var a: String;
|
||||
var b: NotString;
|
||||
|
||||
a = x;
|
||||
a = b;
|
||||
a = x;
|
||||
a = b;
|
||||
|
||||
b = a;
|
||||
b = x;
|
||||
b = a;
|
||||
b = x;
|
||||
|
||||
x = a; // expected error
|
||||
x = b; // expected error
|
||||
|
||||
@@ -41,35 +41,37 @@ interface NotString {
|
||||
>localeCompare : Symbol(NotString.localeCompare, Decl(assignFromStringInterface2.ts, 11, 65))
|
||||
>that : Symbol(that, Decl(assignFromStringInterface2.ts, 12, 18))
|
||||
|
||||
match(regexp: string): string[];
|
||||
>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 36))
|
||||
match(regexp: string): RegExpMatchArray;
|
||||
>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 44))
|
||||
>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 13, 10))
|
||||
>RegExpMatchArray : Symbol(RegExpMatchArray, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
match(regexp: RegExp): string[];
|
||||
>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 36))
|
||||
match(regexp: RegExp): RegExpMatchArray;
|
||||
>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 44))
|
||||
>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 14, 10))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>RegExpMatchArray : Symbol(RegExpMatchArray, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
replace(searchValue: string, replaceValue: string): string;
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 44), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 15, 12))
|
||||
>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 15, 32))
|
||||
|
||||
replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string;
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 44), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 16, 12))
|
||||
>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 16, 32))
|
||||
>substring : Symbol(substring, Decl(assignFromStringInterface2.ts, 16, 48))
|
||||
>args : Symbol(args, Decl(assignFromStringInterface2.ts, 16, 66))
|
||||
|
||||
replace(searchValue: RegExp, replaceValue: string): string;
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 44), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 17, 12))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 17, 32))
|
||||
|
||||
replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string;
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 44), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63))
|
||||
>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 18, 12))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 18, 32))
|
||||
@@ -147,19 +149,19 @@ var b: NotString;
|
||||
>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3))
|
||||
>NotString : Symbol(NotString, Decl(assignFromStringInterface2.ts, 2, 1))
|
||||
|
||||
a = x;
|
||||
a = x;
|
||||
>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3))
|
||||
>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3))
|
||||
|
||||
a = b;
|
||||
a = b;
|
||||
>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3))
|
||||
>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3))
|
||||
|
||||
b = a;
|
||||
b = a;
|
||||
>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3))
|
||||
>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3))
|
||||
|
||||
b = x;
|
||||
b = x;
|
||||
>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3))
|
||||
>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3))
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ interface NotString {
|
||||
>localeCompare : (that: string) => number
|
||||
>that : string
|
||||
|
||||
match(regexp: string): string[];
|
||||
>match : { (regexp: string): string[]; (regexp: RegExp): string[]; }
|
||||
match(regexp: string): RegExpMatchArray;
|
||||
>match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; }
|
||||
>regexp : string
|
||||
|
||||
match(regexp: RegExp): string[];
|
||||
>match : { (regexp: string): string[]; (regexp: RegExp): string[]; }
|
||||
match(regexp: RegExp): RegExpMatchArray;
|
||||
>match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; }
|
||||
>regexp : RegExp
|
||||
|
||||
replace(searchValue: string, replaceValue: string): string;
|
||||
@@ -137,22 +137,22 @@ var a: String;
|
||||
var b: NotString;
|
||||
>b : NotString
|
||||
|
||||
a = x;
|
||||
a = x;
|
||||
>a = x : string
|
||||
>a : String
|
||||
>x : string
|
||||
|
||||
a = b;
|
||||
a = b;
|
||||
>a = b : NotString
|
||||
>a : String
|
||||
>b : NotString
|
||||
|
||||
b = a;
|
||||
b = a;
|
||||
>b = a : String
|
||||
>b : NotString
|
||||
>a : String
|
||||
|
||||
b = x;
|
||||
b = x;
|
||||
>b = x : string
|
||||
>b : NotString
|
||||
>x : string
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
// Repro from #10041
|
||||
|
||||
(''.match(/ /) || []).map(s => s.toLowerCase());
|
||||
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
|
||||
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 2, 26))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 2, 26))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
// Similar cases
|
||||
|
||||
@@ -27,13 +25,11 @@ function f1() {
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : Symbol(z, Decl(bestChoiceType.ts, 9, 7))
|
||||
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(bestChoiceType.ts, 8, 7))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 9, 18))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 9, 18))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
@@ -51,12 +47,10 @@ function f2() {
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : Symbol(z, Decl(bestChoiceType.ts, 15, 7))
|
||||
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(bestChoiceType.ts, 14, 7))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 15, 18))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 15, 18))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
// Repro from #10041
|
||||
|
||||
(''.match(/ /) || []).map(s => s.toLowerCase());
|
||||
>(''.match(/ /) || []).map(s => s.toLowerCase()) : string[]
|
||||
>(''.match(/ /) || []).map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>(''.match(/ /) || []) : RegExpMatchArray
|
||||
>''.match(/ /) || [] : RegExpMatchArray
|
||||
>(''.match(/ /) || []).map(s => s.toLowerCase()) : any[]
|
||||
>(''.match(/ /) || []).map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>(''.match(/ /) || []) : RegExpMatchArray | []
|
||||
>''.match(/ /) || [] : RegExpMatchArray | []
|
||||
>''.match(/ /) : RegExpMatchArray | null
|
||||
>''.match : (regexp: string | RegExp) => RegExpMatchArray | null
|
||||
>'' : ""
|
||||
>match : (regexp: string | RegExp) => RegExpMatchArray | null
|
||||
>/ / : RegExp
|
||||
>[] : never[]
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
>s.toLowerCase : () => string
|
||||
>s : string
|
||||
>toLowerCase : () => string
|
||||
>[] : []
|
||||
>map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>s => s.toLowerCase() : (s: any) => any
|
||||
>s : any
|
||||
>s.toLowerCase() : any
|
||||
>s.toLowerCase : any
|
||||
>s : any
|
||||
>toLowerCase : any
|
||||
|
||||
// Similar cases
|
||||
|
||||
@@ -34,23 +34,23 @@ function f1() {
|
||||
>/ / : RegExp
|
||||
|
||||
let y = x || [];
|
||||
>y : RegExpMatchArray
|
||||
>x || [] : RegExpMatchArray
|
||||
>y : RegExpMatchArray | []
|
||||
>x || [] : RegExpMatchArray | []
|
||||
>x : RegExpMatchArray | null
|
||||
>[] : never[]
|
||||
>[] : []
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : string[]
|
||||
>y.map(s => s.toLowerCase()) : string[]
|
||||
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>y : RegExpMatchArray
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
>s.toLowerCase : () => string
|
||||
>s : string
|
||||
>toLowerCase : () => string
|
||||
>z : any[]
|
||||
>y.map(s => s.toLowerCase()) : any[]
|
||||
>y.map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>y : RegExpMatchArray | []
|
||||
>map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>s => s.toLowerCase() : (s: any) => any
|
||||
>s : any
|
||||
>s.toLowerCase() : any
|
||||
>s.toLowerCase : any
|
||||
>s : any
|
||||
>toLowerCase : any
|
||||
}
|
||||
|
||||
function f2() {
|
||||
@@ -65,23 +65,23 @@ function f2() {
|
||||
>/ / : RegExp
|
||||
|
||||
let y = x ? x : [];
|
||||
>y : RegExpMatchArray
|
||||
>x ? x : [] : RegExpMatchArray
|
||||
>y : RegExpMatchArray | never[]
|
||||
>x ? x : [] : RegExpMatchArray | never[]
|
||||
>x : RegExpMatchArray | null
|
||||
>x : RegExpMatchArray
|
||||
>[] : never[]
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : string[]
|
||||
>y.map(s => s.toLowerCase()) : string[]
|
||||
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>y : RegExpMatchArray
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
>s.toLowerCase : () => string
|
||||
>s : string
|
||||
>toLowerCase : () => string
|
||||
>z : any[]
|
||||
>y.map(s => s.toLowerCase()) : any[]
|
||||
>y.map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>y : RegExpMatchArray | never[]
|
||||
>map : (<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[])
|
||||
>s => s.toLowerCase() : (s: any) => any
|
||||
>s : any
|
||||
>s.toLowerCase() : any
|
||||
>s.toLowerCase : any
|
||||
>s : any
|
||||
>toLowerCase : any
|
||||
}
|
||||
|
||||
|
||||
@@ -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:1486:13: 'Array' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1490: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]]'.
|
||||
|
||||
@@ -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:1451:24: The expected type comes from the return type of this signature.
|
||||
!!! related TS6502 /.ts/lib.es5.d.ts:1457:27: The expected type comes from the return type of this signature.
|
||||
!!! 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.
|
||||
~~
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.
|
||||
|
||||
@@ -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(1472,5): error TS2374: Duplicate index signature for type 'number'.
|
||||
lib.es5.d.ts(1476,5): error TS2374: Duplicate index signature for type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ====
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/firstMatchRegExpMatchArray.ts(5,11): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/firstMatchRegExpMatchArray.ts (1 errors) ====
|
||||
const match = ''.match(/ /)
|
||||
|
||||
if (match !== null) {
|
||||
const foo: string = match[0]
|
||||
const bar: string = match[1]
|
||||
~~~
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [firstMatchRegExpMatchArray.ts]
|
||||
const match = ''.match(/ /)
|
||||
|
||||
if (match !== null) {
|
||||
const foo: string = match[0]
|
||||
const bar: string = match[1]
|
||||
}
|
||||
|
||||
|
||||
//// [firstMatchRegExpMatchArray.js]
|
||||
"use strict";
|
||||
var match = ''.match(/ /);
|
||||
if (match !== null) {
|
||||
var foo = match[0];
|
||||
var bar = match[1];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/firstMatchRegExpMatchArray.ts ===
|
||||
const match = ''.match(/ /)
|
||||
>match : Symbol(match, Decl(firstMatchRegExpMatchArray.ts, 0, 5))
|
||||
>''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
|
||||
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
if (match !== null) {
|
||||
>match : Symbol(match, Decl(firstMatchRegExpMatchArray.ts, 0, 5))
|
||||
|
||||
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, --, --))
|
||||
|
||||
const bar: string = match[1]
|
||||
>bar : Symbol(bar, Decl(firstMatchRegExpMatchArray.ts, 4, 9))
|
||||
>match : Symbol(match, Decl(firstMatchRegExpMatchArray.ts, 0, 5))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/firstMatchRegExpMatchArray.ts ===
|
||||
const match = ''.match(/ /)
|
||||
>match : RegExpMatchArray | null
|
||||
>''.match(/ /) : RegExpMatchArray | null
|
||||
>''.match : (regexp: string | RegExp) => RegExpMatchArray | null
|
||||
>'' : ""
|
||||
>match : (regexp: string | RegExp) => RegExpMatchArray | null
|
||||
>/ / : RegExp
|
||||
|
||||
if (match !== null) {
|
||||
>match !== null : boolean
|
||||
>match : RegExpMatchArray | null
|
||||
>null : null
|
||||
|
||||
const foo: string = match[0]
|
||||
>foo : string
|
||||
>match[0] : string
|
||||
>match : RegExpMatchArray
|
||||
>0 : 0
|
||||
|
||||
const bar: string = match[1]
|
||||
>bar : string
|
||||
>match[1] : string | undefined
|
||||
>match : RegExpMatchArray
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@@ -36,19 +36,19 @@ const repro_43249 = (value: unknown) => {
|
||||
>"No" : "No"
|
||||
}
|
||||
const match = value.match(/anything/) || [];
|
||||
>match : RegExpMatchArray
|
||||
>value.match(/anything/) || [] : RegExpMatchArray
|
||||
>match : [] | RegExpMatchArray
|
||||
>value.match(/anything/) || [] : RegExpMatchArray | []
|
||||
>value.match(/anything/) : RegExpMatchArray | null
|
||||
>value.match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
|
||||
>value : string
|
||||
>match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
|
||||
>/anything/ : RegExp
|
||||
>[] : never[]
|
||||
>[] : []
|
||||
|
||||
const [, extracted] = match;
|
||||
> : undefined
|
||||
>extracted : string
|
||||
>match : RegExpMatchArray
|
||||
>match : [] | RegExpMatchArray
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ const [, a = ''] = ''.match('') || [];
|
||||
> : undefined
|
||||
>a : string
|
||||
>'' : ""
|
||||
>''.match('') || [] : RegExpMatchArray
|
||||
>''.match('') || [] : RegExpMatchArray | []
|
||||
>''.match('') : RegExpMatchArray
|
||||
>''.match : (regexp: string | RegExp) => RegExpMatchArray
|
||||
>'' : ""
|
||||
>match : (regexp: string | RegExp) => RegExpMatchArray
|
||||
>'' : ""
|
||||
>[] : undefined[]
|
||||
>[] : []
|
||||
|
||||
a.toFixed()
|
||||
>a.toFixed() : any
|
||||
|
||||
@@ -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>[]): number[]; (...items: (number | ConcatArray<number>)[]): 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: { <S extends number>(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: <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]; filter: { <S extends number>(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; <U>(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; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; find: { <S extends number>(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<number>; values: () => IterableIterator<number>; includes: (searchElement: number, fromIndex?: number) => boolean; flatMap: <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]; flat: <A, D extends number = 1>(this: A, depth?: D) => FlatArray<A, D>[]; [iterator]: () => IterableIterator<number>; [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:1295:5: 'length' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1299:5: 'length' is declared here.
|
||||
|
||||
@@ -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:1045:5: 'message' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here.
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
@@ -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:1045:5: 'message' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here.
|
||||
}
|
||||
|
||||
if (x instanceof Date) {
|
||||
|
||||
@@ -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:1045:5: 'message' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1049:5: 'message' is declared here.
|
||||
}
|
||||
|
||||
if (isDate(x)) {
|
||||
|
||||
@@ -7,8 +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, --, --))
|
||||
|
||||
m?.[0]! && m[0];
|
||||
>m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5))
|
||||
>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --))
|
||||
>m : Symbol(m, Decl(narrowingWithNonNullExpression.ts, 0, 5))
|
||||
>0 : Symbol(RegExpMatchArray[0], Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
|
||||
@@ -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:1041:13: 'RegExp' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1045:13: 'RegExp' is declared here.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
@@ -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:1041:13: 'RegExp' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1045:13: 'RegExp' is declared here.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
|
||||
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
var \u041A = 1;
|
||||
if (К !== 1) {
|
||||
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
|
||||
}
|
||||
@@ -3809,6 +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, --, --))
|
||||
|
||||
var code = readFile(path);
|
||||
>code : Symbol(code, Decl(parserharness.ts, 1288, 15))
|
||||
@@ -3946,6 +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, --, --))
|
||||
|
||||
var dependencies = units.slice(0, units.length - 1);
|
||||
>dependencies : Symbol(dependencies, Decl(parserharness.ts, 1329, 15))
|
||||
@@ -5698,6 +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, --, --))
|
||||
>callback : Symbol(callback, Decl(parserharness.ts, 1869, 51))
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
|
||||
!!! error TS2769: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1531:5: 'catch' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1535: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
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
|
||||
~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
|
||||
!!! error TS2345: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1531:5: 'catch' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here.
|
||||
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
|
||||
|
||||
var r11: IPromise<number>;
|
||||
|
||||
@@ -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<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
|
||||
!!! error TS2769: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1531:5: 'catch' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1535: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 '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<unknown>'.
|
||||
!!! error TS2345: Property 'catch' is missing in type 'IPromise<any>' but required in type 'Promise<unknown>'.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1531:5: 'catch' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1535:5: 'catch' is declared here.
|
||||
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
|
||||
@@ -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 '<T>(n: number, s: string) => number' but required in type 'ArrayConstructor'.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1482:5: 'isArray' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1486:5: 'isArray' is declared here.
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
|
||||
|
||||
@@ -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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059: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:1055:13: 'Error' is declared here.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1059:13: 'Error' is declared here.
|
||||
}
|
||||
var \u041A = 1;
|
||||
if (К !== 1) {
|
||||
|
||||
@@ -48,7 +48,7 @@ class C implements String {
|
||||
indexOf(searchString: string, position?: number): number { return null; }
|
||||
lastIndexOf(searchString: string, position?: number): number { return null; }
|
||||
localeCompare(that: string): number { return null; }
|
||||
match(regexp: any): string[] { return null; }
|
||||
match(regexp: any): RegExpMatchArray { return null; }
|
||||
replace(searchValue: any, replaceValue: any): string { return null; }
|
||||
search(regexp: any): number { return null; }
|
||||
slice(start?: number, end?: number): string { return null; }
|
||||
@@ -64,7 +64,7 @@ class C implements String {
|
||||
valueOf(): string { return null; }
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
|
||||
// BUG 831846
|
||||
function f10(x: 'a');
|
||||
function f10(x: C);
|
||||
@@ -98,7 +98,8 @@ function f15<T, U extends T>(x: any) { }
|
||||
|
||||
function f16<T extends String, U extends T>(x: 'a');
|
||||
function f16<T extends String, U extends T>(x: U);
|
||||
function f16<T extends String, U extends T>(x: any) { }
|
||||
function f16<T extends String, U extends T>(x: any) { }
|
||||
|
||||
|
||||
//// [stringLiteralTypeIsSubtypeOfString.js]
|
||||
// string literal types are subtypes of string, any
|
||||
|
||||
@@ -148,12 +148,13 @@ class C implements String {
|
||||
>localeCompare : Symbol(C.localeCompare, Decl(stringLiteralTypeIsSubtypeOfString.ts, 47, 81))
|
||||
>that : Symbol(that, Decl(stringLiteralTypeIsSubtypeOfString.ts, 48, 18))
|
||||
|
||||
match(regexp: any): string[] { return null; }
|
||||
match(regexp: any): RegExpMatchArray { return null; }
|
||||
>match : Symbol(C.match, Decl(stringLiteralTypeIsSubtypeOfString.ts, 48, 56))
|
||||
>regexp : Symbol(regexp, Decl(stringLiteralTypeIsSubtypeOfString.ts, 49, 10))
|
||||
>RegExpMatchArray : Symbol(RegExpMatchArray, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
replace(searchValue: any, replaceValue: any): string { return null; }
|
||||
>replace : Symbol(C.replace, Decl(stringLiteralTypeIsSubtypeOfString.ts, 49, 49))
|
||||
>replace : Symbol(C.replace, Decl(stringLiteralTypeIsSubtypeOfString.ts, 49, 57))
|
||||
>searchValue : Symbol(searchValue, Decl(stringLiteralTypeIsSubtypeOfString.ts, 50, 12))
|
||||
>replaceValue : Symbol(replaceValue, Decl(stringLiteralTypeIsSubtypeOfString.ts, 50, 29))
|
||||
|
||||
@@ -205,7 +206,7 @@ class C implements String {
|
||||
[index: number]: string;
|
||||
>index : Symbol(index, Decl(stringLiteralTypeIsSubtypeOfString.ts, 63, 5))
|
||||
}
|
||||
|
||||
|
||||
// BUG 831846
|
||||
function f10(x: 'a');
|
||||
>f10 : Symbol(f10, Decl(stringLiteralTypeIsSubtypeOfString.ts, 64, 1), Decl(stringLiteralTypeIsSubtypeOfString.ts, 67, 21), Decl(stringLiteralTypeIsSubtypeOfString.ts, 68, 19))
|
||||
|
||||
@@ -151,8 +151,8 @@ class C implements String {
|
||||
>that : string
|
||||
>null : null
|
||||
|
||||
match(regexp: any): string[] { return null; }
|
||||
>match : (regexp: any) => string[]
|
||||
match(regexp: any): RegExpMatchArray { return null; }
|
||||
>match : (regexp: any) => RegExpMatchArray
|
||||
>regexp : any
|
||||
>null : null
|
||||
|
||||
@@ -221,7 +221,7 @@ class C implements String {
|
||||
[index: number]: string;
|
||||
>index : number
|
||||
}
|
||||
|
||||
|
||||
// BUG 831846
|
||||
function f10(x: 'a');
|
||||
>f10 : { (x: 'a'): any; (x: C): any; }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @strict: true
|
||||
// @noUncheckedIndexedAccess: true
|
||||
|
||||
const match = ''.match(/ /)
|
||||
|
||||
if (match !== null) {
|
||||
const foo: string = match[0]
|
||||
const bar: string = match[1]
|
||||
}
|
||||
@@ -11,8 +11,8 @@ interface NotString {
|
||||
indexOf(searchString: string, position?: number): number;
|
||||
lastIndexOf(searchString: string, position?: number): number;
|
||||
localeCompare(that: string): number;
|
||||
match(regexp: string): string[];
|
||||
match(regexp: RegExp): string[];
|
||||
match(regexp: string): RegExpMatchArray;
|
||||
match(regexp: RegExp): RegExpMatchArray;
|
||||
replace(searchValue: string, replaceValue: string): string;
|
||||
replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string;
|
||||
replace(searchValue: RegExp, replaceValue: string): string;
|
||||
@@ -38,11 +38,11 @@ var x = '';
|
||||
var a: String;
|
||||
var b: NotString;
|
||||
|
||||
a = x;
|
||||
a = b;
|
||||
a = x;
|
||||
a = b;
|
||||
|
||||
b = a;
|
||||
b = x;
|
||||
b = a;
|
||||
b = x;
|
||||
|
||||
x = a; // expected error
|
||||
x = b; // expected error
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ class C implements String {
|
||||
indexOf(searchString: string, position?: number): number { return null; }
|
||||
lastIndexOf(searchString: string, position?: number): number { return null; }
|
||||
localeCompare(that: string): number { return null; }
|
||||
match(regexp: any): string[] { return null; }
|
||||
match(regexp: any): RegExpMatchArray { return null; }
|
||||
replace(searchValue: any, replaceValue: any): string { return null; }
|
||||
search(regexp: any): number { return null; }
|
||||
slice(start?: number, end?: number): string { return null; }
|
||||
@@ -63,7 +63,7 @@ class C implements String {
|
||||
valueOf(): string { return null; }
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
|
||||
// BUG 831846
|
||||
function f10(x: 'a');
|
||||
function f10(x: C);
|
||||
@@ -97,4 +97,4 @@ function f15<T, U extends T>(x: any) { }
|
||||
|
||||
function f16<T extends String, U extends T>(x: 'a');
|
||||
function f16<T extends String, U extends T>(x: U);
|
||||
function f16<T extends String, U extends T>(x: any) { }
|
||||
function f16<T extends String, U extends T>(x: any) { }
|
||||
|
||||
Reference in New Issue
Block a user