Hig*_*igh 4 nested interface class typescript
我找不到有关此的任何文章。
我如何定义一个嵌套interface在class?
export class Car {
export interface Config {
name : string
}
constructor ( config : Config ) { }
}
Run Code Online (Sandbox Code Playgroud)
您不能直接这样做。但是,至少可以从外部使用者的角度出发,可以使用名称空间类合并来达到所需的效果:
export class Car {
constructor(config: Car.Config) { }
}
namespace Car {
export interface Config {
name: string
}
}
let c: Car.Config;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1615 次 |
| 最近记录: |