1

我正在使用 Typescript 开发 Angular2 应用程序,每次运行 Typescript 转译器时,它都会创建spec.ts文件。它们是源文件的单元测试,因为 Angular2 应用程序的约定是每个文件都有这个.ts文件。

因为目前我不想做任何测试,所以我想暂时禁用 spec.ts 文件的生成,这对我的源文件处理有点混乱。

你知道怎么做吗?

编辑:这是我的tsconfig.json文件:

{
    "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "outDir": "dist",
    "rootDir": "./src",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node"
  },
  "exclude": [
    "typings/main.d.ts",
    "typings/main",
    "node_modules"
  ]
}
4

1 回答 1

2

You can configure your tsconfig.json file to achieve this. You can specify which files to compile by adding them to the files array or you can tell typescript to exclude a certain file or folder by including it in the exclude array.

Here is the link from the official docs.

But as far as i can tell you can't provide a patter like so: '/**.spec.ts'

于 2016-07-19T13:57:58.480 回答