I know this below code is stupid. But in real time it may possible while compiling with two different data with same type.
if (false === true) {}// getting error
operator '===' cannot be applied to types 'false' and 'true'
But Object.is()
is accepting this different data without any error and it returning false
I know the difference between them. But why typescript throwing syntax error as same time why Object.is()
not throwing that error.
Also this error message is correct? or not?
operator '===' cannot be applied to types 'false' and 'true. it should be like operator '===' cannot be applied to types 'Boolean' and 'Boolean'
If the message is wrong, then it solved in any upgraded versions? I m using typescript 2.0.3 version.
This problem is occurred in this below scenarios
1
Object.is("string", "string"); if ("string" === "string1") { }
2
Object.is(1, 2); if (1 === 2) { }
etc..