Skip to content

Recent --strictNullChecks issue w/ && || type result check #9113

Closed
@GoToLoop

Description

@GoToLoop

About 1 weak ago, this sample below would transpile flawlessly under --strictNullChecks:

let sinOrCos = Math.random() < .5;

let choice = sinOrCos && Math.sin || Math.cos;
//let choice = sinOrCos? Math.sin : Math.cos;

alert(choice(Math.PI));

But to my surprise today, under typescript@1.9.0-dev.20160612-1.0, only the statement using the ternary conditional operator works now!

Somehow TS thinks that choice could be boolean as well when using && + || expression. =(
Is that intentional from now on? I miss when it was smarter just 1 week ago. :-(

tsc --pretty --newLine LF --removeComments --experimentalDecorators --strictNullChecks -d -t ES6 sinCos

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions