打字稿错误地抱怨条件永远是真的

时间:2020-06-26 14:53:19

标签: typescript

以以下代码段为例:

getClaims

如您所见,此类中的变量class A { private foo : number = 3; public method () { if (this.foo === 3) { this.anotherMethod(); if (this.foo === 4) { console.log(this.foo); } } } public anotherMethod () { this.foo = 4; } } 通过方法foo进行了更改。假设变量始终为“ 3”。但是Typescript对此并不“同意”。它继续显示错误:

anotherMethod

我如何关闭它?

0 个答案:

没有答案