Closed
Description
I'm getting errors compiling after an update to 2.2.1.
The tsconfig.json file does not specify strictNullChecks, and the problem persists even when strictNullChecks are explicitly set to false.
TypeScript Version: 2.2.1
Code
console.log( 3 | null);
Expected behavior:
Successful compilation
Actual behavior:
error TS2531: Object is possibly 'null'
Activity
mhegazy commentedon Mar 1, 2017
did you mean
3 || null
?sweko commentedon Mar 2, 2017
3 || null works as expected, but 3 | null does not.
In the specific case where I've encountered the issue, it was indeed an error where I've meant to do || but did | instead.
Nonetheless, I've gotten a build error on upgrading typescript, and this is not mentioned anywhere as a breaking change.
gcnew commentedon Mar 2, 2017
It's caused by #13483 and is mentioned in What's new in TypeScript - Better checking for null/undefined in operands of expressions. Sure, it can be seen as a breaking change although the better interpretation would be an error that hadn't been previously caught.