【发布时间】:2015-10-29 08:00:46
【问题描述】:
我想创建一个接口,其中属性可以是string 或Function,必须返回string。我目前有以下:
interface IExample {
prop: string|Function;
}
但这对我来说不够明确,因为Function 可以返回任何东西。我想告诉编译器返回值必须是string。
这在 TypeScript 中怎么可能?或者有可能吗?
【问题讨论】:
标签: typescript declaration tsd