1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
=== tests/cases/compiler/bestChoiceType.ts ===
// Repro from #10041
(''.match(/ /) || []).map(s => s.toLowerCase());
>(''.match(/ /) || []).map : Symbol(Array.map, 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, --, --))
>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
function f1() {
>f1 : Symbol(f1, Decl(bestChoiceType.ts, 2, 48))
let x = ''.match(/ /);
>x : Symbol(x, Decl(bestChoiceType.ts, 7, 7))
>''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
let y = x || [];
>y : Symbol(y, Decl(bestChoiceType.ts, 8, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 7, 7))
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 : Symbol(y, Decl(bestChoiceType.ts, 8, 7))
>map : Symbol(Array.map, 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() {
>f2 : Symbol(f2, Decl(bestChoiceType.ts, 10, 1))
let x = ''.match(/ /);
>x : Symbol(x, Decl(bestChoiceType.ts, 13, 7))
>''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --))
let y = x ? x : [];
>y : Symbol(y, Decl(bestChoiceType.ts, 14, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 13, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 13, 7))
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 : Symbol(y, Decl(bestChoiceType.ts, 14, 7))
>map : Symbol(Array.map, 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, --, --))
}
|