Comma operator seems to confuse nullish coalescing
DRANK
🔎 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 declare const maybe: true | null; let i = 0; // This works const a = maybe ?? true; // This works const b = (i++, maybe); const c = b ?? true; // This fails const d = (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
👀 github.com/microsoft/Type…