diff --git a/tests/cases/compiler/strictNullLogicalAndOr.ts b/tests/cases/compiler/strictNullLogicalAndOr.ts new file mode 100644 index 00000000000..68055f8b20b --- /dev/null +++ b/tests/cases/compiler/strictNullLogicalAndOr.ts @@ -0,0 +1,15 @@ +// @strictNullChecks: true + +// Repro from #9113 + +let sinOrCos = Math.random() < .5; +let choice = sinOrCos && Math.sin || Math.cos; + +choice(Math.PI); + +function sq(n?: number): number { + const r = n !== undefined && n*n || 0; + return r; +} + +sq(3); \ No newline at end of file