在打字稿中,接口是否总是需要导出。在以下情况下出现错误:
错误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() {
...
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句