
[英]How can I create an object based on an interface file definition in TypeScript?
[英]can you create a ts definition that checks for ANY typescript interface?
我有一个接口,我想在我的定义中强制定义一个接口,但允许使用任何接口。 就像是...
interface Foo {
enabled: boolean
}
interface Settings {
[key: string]: AnyInterface
// will pass
foo: IFoo;
// will fail
bar: {
key: string;
}
}
我想避免[key: string]: IFoo | IBar | ...
[key: string]: IFoo | IBar | ...
[key: string]: IFoo | IBar | ...
这可能吗? 或者可能是一个更好的解决方案?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.