🔎 Search Terms
T to null
🕗 Version & Regression Information
- This is a type narrowing issue
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-pr-57465-110#code/GYVwdgxgLglg9mABDAzgORAG0wHgCoB8AFAG4CGmIApgFyJ4CUiA3gFAD07i3P3AegH5W3GMESkK1RAF5ZiMFkxM2vcpSrdO9ADSIUACzhYAJogBGGhdmGIAvqxsAnKlBCOkaqbOnzFAblZ7IA
💻 Code
function isNull<T>(value: T) {
if (value === null) {
value // T, should be null
}
return value === null;
}
🙁 Actual behavior
value is T inside the if block of value === null (explicit comparison)
🙂 Expected behavior
value should be of type null inside the if block of value === null
Additional information about the issue
No response
🔎 Search Terms
T to null
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-pr-57465-110#code/GYVwdgxgLglg9mABDAzgORAG0wHgCoB8AFAG4CGmIApgFyJ4CUiA3gFAD07i3P3AegH5W3GMESkK1RAF5ZiMFkxM2vcpSrdO9ADSIUACzhYAJogBGGhdmGIAvqxsAnKlBCOkaqbOnzFAblZ7IA
💻 Code
🙁 Actual behavior
value is T inside the if block of value === null (explicit comparison)
🙂 Expected behavior
value should be of type null inside the if block of value === null
Additional information about the issue
No response