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
See https://tsplay.dev/Nr8YVW - it seems like the type narrowing allows truthy/falsy checks, but doesn't support when the predicate's return value is explicitly compared to true or false.
🔎 Search Terms
i guess type narrowing, predicates?
🕗 Version & Regression Information
This occurs in the latest nightly on the TS playground; see above. I assume it's always been the case since predicate support was added, but haven't checked.
functionisFunction(x: unknown): x is Function{returntypeofx==='function';}constx: unknown=function(){};if(isFunction(x)){x;// x is a function here}if(!isFunction(x)){x;// x is not a function here (should be more specific than `unknown`, but ¯\_(ツ)_/¯)}if(isFunction(x)!==false){x;// x should be a function here}if(isFunction(x)===true){x;// x should be a function here}
🙁 Actual behavior
See above.
🙂 Expected behavior
See above.
The text was updated successfully, but these errors were encountered:
Bug Report
See https://tsplay.dev/Nr8YVW - it seems like the type narrowing allows truthy/falsy checks, but doesn't support when the predicate's return value is explicitly compared to
true
orfalse
.🔎 Search Terms
i guess type narrowing, predicates?
🕗 Version & Regression Information
This occurs in the latest nightly on the TS playground; see above. I assume it's always been the case since predicate support was added, but haven't checked.
⏯ Playground Link
https://tsplay.dev/Nr8YVW
💻 Code
🙁 Actual behavior
See above.
🙂 Expected behavior
See above.
The text was updated successfully, but these errors were encountered: