[英]Short Import Typescript path mapping doesnt work in Angular 8 Project
我的 Angular 项目结构如下所示:
我的目标是能够将 register.component.ts 导入到 auth-routing.module.ts 中
import { RegisterComponent } from '@pages/auth/authpages/register/register.component';
为此,我将路径添加到我的 tsconfig.json,如下所示:
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"typeRoots": ["node_modules/@types"],
"importHelpers": true,
"target": "es2015",
"lib": [
"es2018",
"dom"
],
"baseUrl": "src",
"paths": {
"@pages/*": ["app/pages*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
由于某种原因,它仍然无法正常工作。 该组件已正确导出,并且可以使用标准 ts 路径作为目标。 有谁知道问题出在哪里?
尝试改变这个
"@pages/*": ["app/pages*"]
至
"@pages/*": ["app/pages/*"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.