【发布时间】:2021-02-11 15:45:37
【问题描述】:
使用 Typescript,我使用 getter 创建类。我想重新定义一些吸气剂,但使用超级。现在,当我输入以下代码行时,出现以下错误消息:
class A {
protected get style(): React.CSSProperties | undefined {
return {width: '100%'};
}
}
class B extends B {
protected get style(): React.CSSProperties | undefined {
return super.style;
}
}
只有基类的 public 和 protected 方法可以通过 'super' 关键字访问。ts(2340)
如果我输入:
this.super.style
,编辑器(VSCode)告诉我super在这上面不存在
类型 'A'.ts(2339) 上不存在属性 'super'
【问题讨论】:
标签: typescript eslint getter-setter super