[英]Lazy-loaded modules warnings after updating Angular from 8 to 9
After Angular update all lazy-loaded modules return warning: Angular 更新所有延迟加载模块后返回警告:
Error: [path/to/module/module-name.ts] is missing from the TypeScript
compilation. Please make sure it is in your tsconfig via the 'files'
or 'include' property.
My function which returns modules array:我的 function 返回模块数组:
export function manifests(prefix = '') {
return [
{
loadChildren: () => import(prefix + '/path/to/a.module').then(m => m.AModule),
path: 'a',
},
{
loadChildren: () => import(prefix + '/path/to/b.module').then(m => m.BModule),
path: 'b',
},
]
}
If I replace that function with static array everything seems to be fine, though.如果我用 static 数组替换 function ,那么一切似乎都很好。 Why?为什么?
My tsconfig.app.json:我的 tsconfig.app.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts",
"src/zone-flags.ts",
],
"include": [
"src/**/*.d.ts",
]
}
In my case, for some reason, the file name in the import statements were capatilized.在我的情况下,由于某种原因,导入语句中的文件名被大写了。
For instance, let's say I had the following.ts file: companySearchModel.ts
例如,假设我有以下.ts 文件: companySearchModel.ts
export class CompanySearchModel {
//some properties
}
The import statement in another file, where the companySearchModel
is used, looked like this:使用companySearchModel
的另一个文件中的导入语句如下所示:
import { CompanySearchModel } from './models/CompanySearchModel.ts'
When it should have looked, like this:当它应该看起来像这样:
import { CompanySearchModel } from './models/companySearchModel.ts'
Not sure why this happened, but hopefully this will help you.不知道为什么会发生这种情况,但希望这会对您有所帮助。
you can add this path to exclude in tsconfig below include property您可以在包含属性下面的 tsconfig 中添加此路径以排除
"exclude": [
"path/to/module"
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.