我在Typescript文件中有一个简单的Javascript类。我把它简化为下面的骨架。
错误消息为Property 'cleanData' does not exist on type 'void'.ts(2339)
我看不出cleanData((的声明和两边的成员函数之间有什么区别,它们似乎都很好。。。
我能做些什么来解决这个问题?谢谢
export class Smokechart {
constructor() {
}
addProps() {
}
cleanData() {
}
adjustScaleRange() {
}
fillSmoke() {
}
chart() {
}
computeMedianLine() {
}
computeSmokeAreas() {
}
_quantile() {
}
_calculateSmokeBounds() {
}
}
const chainableInstance = new Smokechart()
chainableInstance
.addProps()
.cleanData() // <== Property 'cleanData' does not exist on type 'void'.ts(2339)
.adjustScaleRange()
.computeMedianLine()
.computeSmokeAreas()
.fillSmoke()
.chart()
._quantile()
._calculateSmokeBounds()
@Jared Smith在评论中提到
您不会从addProps返回任何内容,因此编译器当然不会让您链接另一个方法。
它太";骨架化";。添加";返回此";因为每个方法的主体都消除了错误。