You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionf(_: string){};letx: string|undefined;constq: boolean=true;constqc=falseasconst;q ? x ? f(x) : null : null;qc ? x ? f(x) : null : null;// no error as below despite qc being `const false` so it should behave the same?false ? x ? f(x) : null : null;// error on `x` being string | undefined in impossible branch after x is checked.
π Actual behavior
π Expected behavior
Either disable typechecking in unreachable code or still apply narrowing (as is done in the qc ? ... line)?
Additional information about the issue
Just sharing since it surprised me a little.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
π Search Terms
ternary false inference
π Version & Regression Information
Looks like this has been the case forever. (since oldest playground version 3.3333Μ )
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMAFAfQFyIM5QE4xgDmAlIgN4C+A3AFAA2AplIgB5a4HGIA+i4AE0bBCjAXQgJciAI5YARnDhMAhkgC8ifCEYSpLGRESbgK+tkaIV2RJLC46tGYgD8bV8hSsyWMCHr0iL7+9HSGHqweqN5BiH4BsfGhtKbmlm6RbtE+cSGJIdRAA
π» Code
π Actual behavior
π Expected behavior
Either disable typechecking in unreachable code or still apply narrowing (as is done in the
qc ? ...
line)?Additional information about the issue
Just sharing since it surprised me a little.
The text was updated successfully, but these errors were encountered: