diff --git a/tests/cases/compiler/bestChoiceType.ts b/tests/cases/compiler/bestChoiceType.ts new file mode 100644 index 00000000000..3f8ce4bc868 --- /dev/null +++ b/tests/cases/compiler/bestChoiceType.ts @@ -0,0 +1,19 @@ +// @strictNullChecks: true + +// Repro from #10041 + +(''.match(/ /) || []).map(s => s.toLowerCase()); + +// Similar cases + +function f1() { + let x = ''.match(/ /); + let y = x || []; + let z = y.map(s => s.toLowerCase()); +} + +function f2() { + let x = ''.match(/ /); + let y = x ? x : []; + let z = y.map(s => s.toLowerCase()); +}