我正在使用 Angular 11 并尝试使用短导入import {smthg} from '@common'而不是import {smthg} from '../../../common'
但我总是在 IDEA 中遇到错误: TS2307: Cannot find module '@common' or its corresponding type declarations.
尝试编译 .ts 文件时在控制台中出现同样的错误 ( ng serve)
有趣的是,当我添加/index到导入时,然后IDEA停止诅咒,但错误并没有在控制台中消失
myAngularProject
? package.json
? tsconfig.json
? tsconfig.app.json
? angular.json
?
????src
? main.ts
? index.html
?
????app
?
????common
?
????features
Run Code Online (Sandbox Code Playgroud)
tsconfig.json:
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@common/*": ["app/common/*"],
"@features/*": …Run Code Online (Sandbox Code Playgroud)