Take a look at the code :
export class Smth { private flag: boolean; public update() { this.flag = true; this.inner(); if (this.flag === false) {
I canβt understand what happened to the line
if (this.flag === false)
Typescript says
The operator '===' cannot be applied to the types "true" and "false".
But actually there is boolean and false .
I am using typescript 2.6.2, but the online platform shows the same result with 2.7.
This is not a duplicate. The operator '==' cannot be applied to types x and y in typescript 2 , since this question is about comparing constants. But in my code this is a cool class field, and there is a function that changes the value. Moreover, it is called.
this.flag = true; this.inner(); // exectues this.flag = false; if (this.flag === false) { // ... types 'true' and 'false'. - WHY?
typescript
Qwertiy
source share