![](/img/trans.png)
[英]Typescript complains that private property is not present in the interface
[英]private interface in typescript
在打字稿中,接口是否总是需要导出。 在以下情况下出现错误:
错误TS2019:导出的类'Test'实现了专用接口'ITest'。
module xxx {
interface ITest {
}
export class Test implements ITest {
}
}
您的情况是。 如果要导出实现它的类,则需要:
module xxx {
export interface ITest {
name: string
}
export class Test implements ITest {
name = "ddsd"
constructor() {
...
}
}
}
或者,您可以将ITest移到外面:
interface ITest {
name: string
}
module xxx {
export class Test implements ITest {
name = "ddsd"
constructor() {
...
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.