【发布时间】:2017-05-01 07:03:14
【问题描述】:
我的代码的一个简单实现是这样的:
interface IndexSignature{
[key:string]:any;
}
class Foo implements IndexSignature{
bar(){};
baz(){
this['bar'](); //Error: Element implicitly has an 'any' type because type 'Foo' has no index signature.
}
}
如何向 Foo 类添加索引签名?
【问题讨论】:
标签: typescript