🔎 Search Terms
Ever since Typescript 5.6, we've been getting false positives of the nullish operand lint rule. Our codebase is littered with it so it blocks us from upgrading to the latest Typescript
🕗 Version & Regression Information
- This changed between versions 5.5 and 5.6 (also there on latest 5.7.2)
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABADwDwBUB8AKAzlAJxjAHNcAuRdAUwFsAHAGwEMpqBlQ4sgQQIOYBPADSIAdBIBuzRiGoVEYELQBG1AgG0AugEpK6RAB9FIRo0QBvAFCJbiAtSggCSJWcTNci6pPU27APQBiAB6iIJwIIgQzEgyuHD2dHC+iFAAFtQeKilZjMTUouAOLGwAJmmJGVkqICSiCIyCaZkOlYi4IPT0Dri4-rZBHkjF1KXUFbUkYlYAvlZWQwAicPKKcFCIAO5wBADWlAAy1MCbuDBlWTBeYD7qJmbX6VYQCPiI0rLUlEqq9wC8KFQvzUBEwAAN0jBwYgAPywxAABgWQwA6rs9rhYS83ptPnIAEyIQFoEHqCFQ8E4sDvfHUADMP2UoOJHxkhLhCORQA
💻 Code
functionx<T>(strings: TemplateStringsArray, ...values: number[]): T|null{returnnullasnever// ^ you can also remove the above line, unrelated to the bug, only there to suppress// an unrelated error.}// Does not work: Left side is never nullishconstvalue: number=x<number>`hi`??0// ^ this line causes an error in Typescript// Works?constvalue2=x<number>`hi`constvalue3: number=value2??0🙁 Actual behavior
Right operand of ?? is unreachable because the left operand is never nullish
🙂 Expected behavior
No error
Additional information about the issue
I tried looking for duplicate issues but wasn't able to find any. If the bug has already been filed, a link to it would be appreciated. Thanks!
🔎 Search Terms
Ever since Typescript 5.6, we've been getting false positives of the nullish operand lint rule. Our codebase is littered with it so it blocks us from upgrading to the latest Typescript
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABADwDwBUB8AKAzlAJxjAHNcAuRdAUwFsAHAGwEMpqBlQ4sgQQIOYBPADSIAdBIBuzRiGoVEYELQBG1AgG0AugEpK6RAB9FIRo0QBvAFCJbiAtSggCSJWcTNci6pPU27APQBiAB6iIJwIIgQzEgyuHD2dHC+iFAAFtQeKilZjMTUouAOLGwAJmmJGVkqICSiCIyCaZkOlYi4IPT0Dri4-rZBHkjF1KXUFbUkYlYAvlZWQwAicPKKcFCIAO5wBADWlAAy1MCbuDBlWTBeYD7qJmbX6VYQCPiI0rLUlEqq9wC8KFQvzUBEwAAN0jBwYgAPywxAABgWQwA6rs9rhYS83ptPnIAEyIQFoEHqCFQ8E4sDvfHUADMP2UoOJHxkhLhCORQA
💻 Code
🙁 Actual behavior
🙂 Expected behavior
No error
Additional information about the issue
I tried looking for duplicate issues but wasn't able to find any. If the bug has already been filed, a link to it would be appreciated. Thanks!