[英]private interface in typescript
In typescript, does interface always needs to be exported. 在打字稿中,接口是否总是需要导出。 I get error in the below case:
在以下情况下出现错误:
error TS2019: Exported class 'Test' implements private interface 'ITest'. 错误TS2019:导出的类'Test'实现了专用接口'ITest'。
module xxx {
interface ITest {
}
export class Test implements ITest {
}
}
In your case yes. 您的情况是。 You need to if you want to export the class that implements it:
如果要导出实现它的类,则需要:
module xxx {
export interface ITest {
name: string
}
export class Test implements ITest {
name = "ddsd"
constructor() {
...
}
}
}
Alternatively you can move ITest outside: 或者,您可以将ITest移到外面:
interface ITest {
name: string
}
module xxx {
export class Test implements ITest {
name = "ddsd"
constructor() {
...
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.