89 lines
6 KiB
Plaintext
89 lines
6 KiB
Plaintext
=== tests/cases/compiler/bestChoiceType.ts ===
|
|
|
|
// Repro from #10041
|
|
|
|
(''.match(/ /) || []).map(s => s.toLowerCase());
|
|
>(''.match(/ /) || []).map(s => s.toLowerCase()) : string[]
|
|
>(''.match(/ /) || []).map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
|
>(''.match(/ /) || []) : RegExpMatchArray
|
|
>''.match(/ /) || [] : RegExpMatchArray
|
|
>''.match(/ /) : RegExpMatchArray | null
|
|
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>'' : ""
|
|
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>/ / : RegExp
|
|
>[] : never[]
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <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
|
|
|
|
// Similar cases
|
|
|
|
function f1() {
|
|
>f1 : () => void
|
|
|
|
let x = ''.match(/ /);
|
|
>x : RegExpMatchArray | null
|
|
>''.match(/ /) : RegExpMatchArray | null
|
|
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>'' : ""
|
|
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>/ / : RegExp
|
|
|
|
let y = x || [];
|
|
>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>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
|
>y : RegExpMatchArray
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <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
|
|
}
|
|
|
|
function f2() {
|
|
>f2 : () => void
|
|
|
|
let x = ''.match(/ /);
|
|
>x : RegExpMatchArray | null
|
|
>''.match(/ /) : RegExpMatchArray | null
|
|
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>'' : ""
|
|
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
|
>/ / : RegExp
|
|
|
|
let y = x ? x : [];
|
|
>y : RegExpMatchArray
|
|
>x ? x : [] : RegExpMatchArray
|
|
>x : RegExpMatchArray | null
|
|
>x : RegExpMatchArray
|
|
>[] : never[]
|
|
|
|
let z = y.map(s => s.toLowerCase());
|
|
>z : string[]
|
|
>y.map(s => s.toLowerCase()) : string[]
|
|
>y.map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
|
>y : RegExpMatchArray
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <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
|
|
}
|
|
|