Bug Report
π Search Terms
type guard equality narrowing strict equal equality
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/FAMwrgdgxgLglgewgAgEYEMBOAKZWDmAXHhAJ7ICUyA3sMvcnCMrgcgLyfIRgA2vlGnQYjMAUxhhMKAgG5h9AL7AFjZq0z4OXEOl4BnMYNojREqTM3yRy5SqA
π» Code
function bar( arg: any ) {
if ( arg === null ) {
return arg;
}
if ( arg === false ) {
return arg;
}
}
π Actual behavior
arg should be null/false inside the if conditions
π Expected behavior
arg is any
The docs say this should work https://www.typescriptlang.org/docs/handbook/2/narrowing.html
When using unknown instead of any it works perfectly fine. I think adjusting this, so it works for any too, isn't too far fetched.
Bug Report
π Search Terms
type guard equality narrowing strict equal equality
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/FAMwrgdgxgLglgewgAgEYEMBOAKZWDmAXHhAJ7ICUyA3sMvcnCMrgcgLyfIRgA2vlGnQYjMAUxhhMKAgG5h9AL7AFjZq0z4OXEOl4BnMYNojREqTM3yRy5SqA
π» Code
π Actual behavior
arg should be
null/falseinside the if conditionsπ Expected behavior
arg is
anyThe docs say this should work https://www.typescriptlang.org/docs/handbook/2/narrowing.html
When using
unknowninstead ofanyit works perfectly fine. I think adjusting this, so it works foranytoo, isn't too far fetched.