我正在开发Angular.js中的应用。我遇到了@types/angular-mocks
定义适用于src/**
下所有文件的问题。我希望angular-mocks
的定义文件仅适用于与src/**/*.spec.ts
匹配的文件。
d.ts
输出文件以下代码显示了我的典型控制器和d.ts
输出问题:
我-controller.ts
import * as ng from 'angular';
export class MyController {
constructor(public $timeout: ng.ITimeoutService) {}
method() {
// I don't want this method to be shown
this.$timeout.flush();
}
}
我-controller.d.ts
/// <reference types="angular" />
/// <reference types="angular-mocks" />
// I want to prevent the above reference from being added
import * as ng from 'angular';
export declare class MyController {
$timeout: ng.ITimeoutService;
constructor($timeout: ng.ITimeoutService);
method(): void;
}
如果相关,则为tsconfig.json
设置:
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"module": "es2015",
"moduleResolution": "node",
"outDir": "dist",
"newLine": "LF",
"sourceMap": true,
"skipLibCheck": true,
"removeComments": false,
"importHelpers": true,
"noImplicitAny": true,
"strictNullChecks": true,
"experimentalDecorators": true
},
"include": [
"src/**/*"
]
}
我还没有找到一个很好的方法来实现这一目标。任何帮助将不胜感激。