我找不到任何关于此的文章。
如何在 class
中定义嵌套的 interface
?
export class Car {
export interface Config {
name : string
}
constructor ( config : Config ) { }
}
最佳答案
你不能直接这样做。但是至少从外部消费者的角度来看,您可以使用 namespace 类合并来达到预期的效果:
export class Car {
constructor(config: Car.Config) { }
}
namespace Car {
export interface Config {
name: string
}
}
let c: Car.Config;
关于 typescript ,类内的接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54065250/