2017-10-17 63 views
0

我使用的IntelliJ IDEA 2017年2月4日制定角度(4个不是JS)应用程序。一切正常,运行良好,但IntelliJ标记所有@angular导入TypeScript文件与红色的波浪状。角的打字稿的IntelliJ进口标有抽搐

的错误消息是TS2307: Cannot find module '@nagular/abc'

存在Jetbrain的支持Typescript does not resolve modules through tsconfig.json's baseUrl

enter image description here

这是我tsconfig.json文件还发出打开。

请注意,tsconfig.json文件存储不在项目的根,但./app/ui目录 - 如果该事项。

{ 
    "compilerOptions": { 
    "alwaysStrict": true, 
    "noImplicitReturns": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "module": "system", 
    "target": "es5", 
    "removeComments": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "outDir": "generated", 
    "inlineSourceMap": true, 
    "importHelpers": true, 
    "baseUrl": ".", 
    "paths": { 
    "tslib": [ 
     "../../node_modules/tslib/tslib.d.ts" 
    ] 
    }, 
    "skipLibCheck": true, 
    "downlevelIteration": true 
    }, 
    "exclude": [ 
    "lib" 
    ] 
} 
+0

这可能是的IntelliJ期待在'tsconfig.json' –

+0

当你将鼠标悬停在进口的红线它说什么了定义的代码风格? –

+0

我已经添加了错误信息 –

回答

1

你所有的角相关包的应该是 为如:

node_modules/@angular/common/index.d.ts 
node_modules/@angular/compiler/index.d.ts 
node_modules/@angular/core/index.d.ts 
node_modules/@angular/http/index.d.ts 
node_modules/@angular/platform-browser/index.d.ts 
node_modules/@angular/platform-browser-dynamic/index.d.ts 
node_modules/@angular/router/index.d.ts 
node_modules/@angular/router-deprecated/index.d.ts 

然而,所有这些都应该在那里,如果你已经从标准的快速入门https://angular.io/docs/ts/latest/quickstart.html使用的package.json文件并运行npm install

还要检查你的IDE的tsconfig.json设置

File->settings->Languages & Frameworks -> TypeScript ->enable typescript compiler & Use tsconfig.json 
+0

我没有看到任何index.d.ts在这些路径 –

+0

我也没有'启用打字稿Compiler',因为我不想的IntelliJ编译.ts文件 –

0

当使用"module": "system"打字稿采用经典模块的分辨率,这不能解决节点模块,看细节在https://www.typescriptlang.org/docs/handbook/module-resolution.html

要使其工作,你需要切换到不同的模块系统,如CommonJS的,或者有可能是另一种配置在使用"module": "system"时明确包含node_modules的分辨率。