一个错误当使用TSC编译器选项"declaration": true
我得到以下错误:生成与编译器选项d.ts文件生成角
error TS4019: Implements clause of exported class 'MyClass' has or is using private name 'angular'.
使用"declaration": false
时,我没有得到这个错误。
使用打字稿版本: 2.0.3
样品代码:
MyClass.ts
/// <reference path="node_modules/@types/angular/index.d.ts" />
module MyModule {
export class MyClass implements angular.IServiceProvider {
constructor() {
}
$get;
}
}
tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"declaration": true
},
"exclude": [
"node_modules"
]
}
有我S ON https://github.com/iwhp/issues/tree/master/typescript-bug-declaration-file-with-angular
预期的行为GitHub库:
一个.d.ts文件应该被创建。
除样品以上
添加以下类,表明MyClass.ts这里使用。
MyClass2.ts
/// <reference path="node_modules/@types/angular/index.d.ts" />
module MyModule {
export class MyClassB implements angular.IServiceProvider {
constructor(myClass: MyModule.MyClass) {
}
$get;
}
}
Thankx artem。这确实有效,但我现在添加了一个名为MyClassB的新类,它使用MyClass。现在,当使用您的提案时,我收到以下消息:错误TS2305:模块“MyModule”没有导出成员'MyClass'。 – iwhp