一個錯誤當使用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