Lazy-loaded modules warnings after updating Angular from 8 to 9

我是研究僧i 提交于 2020-06-01 07:03:39

问题


After Angular update all lazy-loaded modules return warning:

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:

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. Why?

My 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",
  ]
}

回答1:


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

export class CompanySearchModel {
    //some properties
}

The import statement in another file, where the companySearchModel is used, looked like this:

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.




回答2:


you can add this path to exclude in tsconfig below include property

"exclude": [
    "path/to/module"
  ]


来源:https://stackoverflow.com/questions/61951542/lazy-loaded-modules-warnings-after-updating-angular-from-8-to-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!