【发布时间】:2023-02-10 16:10:06
【问题描述】:
class Foo {
methodA(){}
methodB(){}
runMethod(methodName: string) {
/**
* need to call method dynamically from inheritance method
* but it give error something like This expression is not callable
* Type `unknown` has no call signatures.
**/
this[methodName]()
}
}
如何让它通过打字稿。如果通过输入 // @ts-ignore 告诉打字稿忽略该行,它会起作用,但我想知道这样做的正确方法。
【问题讨论】:
标签: typescript