我有一个角度应用程序,使用@类型和一些自定义类型。由于某些原因,当我为应用程序提供服务时,它可以工作,当我使用ng test运行测试时,它找不到自定义类型。我不明白为什么会这样,我也不明白你应该如何管理扩展配置,或者为什么你想要在服务和测试之间提供不同的类型。
以下是自动生成的配置:
tsconfig.json配置
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json配置
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports" : true,
"outDir": "../out-tsc/app",
"module": "es2015",
"types": []
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
tsconfig.spec.json配置
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs"
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
我已经尝试了很多不同的变化,但仍然不明白为什么它的服务,而不是测试工作。我知道不指定类型数组意味着应该获取所有类型?但事实似乎恰恰相反。
如果有人能透露一些情况,我将不胜感激。