🔎 Search Terms
comma operator nullish coalescing never
🕗 Version & Regression Information
- This changed between versions 5.5.4 and 5.6.3
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.6.3#code/FAEwpgxgNghgTmABBA9gOwM4BdEFsYCeARmAFyJZwCuSAPomlVFANzDBRg4CWiAvIgAMbYAG9giScnTZEMfnkIlEAfhUVqYNoglTUmHEQUAKbgGozAGkXEwASm16ZOCAqNqNNEVOkHEIE3MrGxI7VXVKL2AAX3ZgIA
💻 Code
declareconstmaybe: true|null;leti=0;// This worksconsta=maybe??true;// This worksconstb=(i++,maybe);constc=b??true;// This failsconstd=(i++,maybe)??true;
🙁 Actual behavior
A build error occurs:
Right operand of ?? is unreachable because the left operand is never nullish. ts(2869)
🙂 Expected behavior
The code should compile without error; The left side of the ?? can still be nullish in the const d case.
The const b / const c case is functionally identical and is recognized to be valid
Additional information about the issue
No response
🔎 Search Terms
comma operator nullish coalescing never
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.6.3#code/FAEwpgxgNghgTmABBA9gOwM4BdEFsYCeARmAFyJZwCuSAPomlVFANzDBRg4CWiAvIgAMbYAG9giScnTZEMfnkIlEAfhUVqYNoglTUmHEQUAKbgGozAGkXEwASm16ZOCAqNqNNEVOkHEIE3MrGxI7VXVKL2AAX3ZgIA
💻 Code
🙁 Actual behavior
A build error occurs:
🙂 Expected behavior
The code should compile without error; The left side of the
??can still be nullish in theconst dcase.The
const b/const ccase is functionally identical and is recognized to be validAdditional information about the issue
No response