89 lines
14 KiB
Plaintext
89 lines
14 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: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>(''.match(/ /) || []) : RegExpMatchArray
|
|
>''.match(/ /) || [] : RegExpMatchArray
|
|
>''.match(/ /) : RegExpMatchArray | null
|
|
>''.match : (regexp: string | RegExp) => RegExpMatchArray | null
|
|
>'' : ""
|
|
>match : (regexp: string | RegExp) => RegExpMatchArray | null
|
|
>/ / : RegExp
|
|
>[] : never[]
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>s => s.toLowerCase() : (this: undefined, 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 | RegExp) => RegExpMatchArray | null
|
|
>'' : ""
|
|
>match : (regexp: string | 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: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>y : RegExpMatchArray
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>s => s.toLowerCase() : (this: undefined, 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 | RegExp) => RegExpMatchArray | null
|
|
>'' : ""
|
|
>match : (regexp: string | 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: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>y : RegExpMatchArray
|
|
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
|
>s => s.toLowerCase() : (this: undefined, s: string) => string
|
|
>s : string
|
|
>s.toLowerCase() : string
|
|
>s.toLowerCase : () => string
|
|
>s : string
|
|
>toLowerCase : () => string
|
|
}
|
|
|