I am developing an Ionic 2 rc.1 app and I use idea intelliJ 2016.2.4.
Project runs fine but the IDE don't recognize the typescript definition of Promise because it seems the type "is not included in tsconfig.json'
The inspection error is: Corresponding file is not included in tsconfig.json
my tsconfig.json look like that:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
if I remove node_modules from the "exclude" block then I do not have problem with the IDE inspection but the project run ionic serve
fails in the lint phase.
here is my package.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/compiler-cli": "0.6.2",
"@angular/core": "^2.0.0",
"@angular/forms": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/platform-server": "^2.0.0",
"@ionic/storage": "^1.0.3",
"ionic-angular": "^2.0.0-rc.1",
"ionic-native": "^2.2.3",
"ionicons": "^3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@ionic/app-scripts": "^0.0.36",
"typescript": "^2.0.3"
},
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios@4.2.1",
"android@5.2.2"
]
}
Someone knows how to solve this problem?
Thanks
答案 0 :(得分:6)
最后,我通过解决方法解决了我的问题。
它解决了所有不能将es2015类型识别到IDE中的问题:
先决条件:将Idea IntelliJ升级为> 2016.2.4
首先确保打字稿安装为全局。
npm install -g typescript
在设置中设置上面安装的打字稿版本
在偏好设置中>语言与框架> TypeScript> TypeScript版本>修改
设置npm包的路径。就我而言:/usr/local/lib/node_modules/typescript/lib
最后在选项设置选项的编译器选项中 手动 使用tsconfig.json
在某些情况下,您应该激活选项使用TypeScript服务(实验)
自动填充功能正常,检查员无任何问题。
答案 1 :(得分:1)
我解决了在es6
中将lib
添加到tsconfig.json
部分的问题:
"lib": [
"es2016",
"dom",
"es6" // added
]
希望这有帮助。
答案 2 :(得分:0)
我通过npm安装了@types/es6-shim
并从lib
删除了tsconfig.json
选项。它正在开发PhpStorm 2016.2.2。
答案 3 :(得分:0)
我通过在项目
中的typescript版本全局安装typescript来解决这个问题