TypeScript/tests/cases/compiler/circularOptionalityRemoval.ts
Ryan Cavanaugh c4e96856ac
Detect circularities when removing 'undefined' from defaulted params (#37023)
Fixes #37008

Note that referencing a variable in its initializer is a TDZ error;
the OP report had OOB logic that prevented this in practice (?)
2020-02-26 14:59:04 -08:00

7 lines
191 B
TypeScript

// @strictNullChecks: true
// Constructed repro
function fn1(x: number | undefined = x > 0 ? x : 0) { }
// Report from user
function fn2(x?: string = someCondition ? 'value1' : x) { }