给定一个具有静态属性的类,以及通过this.constructor
访问该属性的方法:
class Matematica {
reset() {
this.constante = this.constructor.PI;
}
}
Matematica.PI = 3.14
Flow无法找到静态属性PI
:
xx: this.constructor.PI;
^^ property `PI`. Property not found in
xx: this.constructor.PI;
^^^^ statics of Matematica
xx: Matematica.PI = {
^^ property `PI`. Property not found in
xx: Matematica.PI = {
^^^^^^^^^^ statics of Matematica
为什么Flow对这个工作代码感到不满意?我该怎么做才能让它在代码或流程配置中变得快乐?
答案 0 :(得分:0)
找到解决方案:
class Matematica {
reset() {
this.constante = this.constructor.PI;
}
static get PI() {
return 3.14
}
}