我正在开发离子2 rc。1 . app和我用idea intelliJ 2016.2.4.
项目运行良好,但IDE不识别Promise的typescript定义,因为似乎类型"不包括在tsconfig.json中"
检测误差为:Corresponding file is not included in tsconfig.json
。Json是这样的:
{
"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
}
}
如果我从"排除"块中删除node_modules,那么我对IDE检查没有问题,但项目运行ionic serve
在lint阶段失败。
这是我的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"
]
}
有人知道怎么解决这个问题吗?谢谢
我终于用一个变通办法解决了我的问题。
解决了所有无法识别的es2015类型进入IDE的问题:
前提条件:将Idea IntelliJ升级到>2016.2.4
- 首先确保typescript是全局安装的。
npm install -g typescript
2. 设置上面安装的typescript版本
在Preferences>语言,框架在打印稿祝辞TypeScript版本>编辑
设置路径为npm package。在我的例子中:/usr/local/lib/node_modules/typescript/lib
-
最后在编译器选项中放上设置选项使用tsconfig.json
-
在某些情况下,你应该激活选项Use TypeScript Service(Experimental)
自动完成工作,检查器没有更多的问题。
我解决了在tsconfig.json
中添加es6
到lib
部分的问题:
"lib": [
"es2016",
"dom",
"es6" // added
]
我通过npm安装了@types/es6-shim
,并从tsconfig.json
中删除了lib
选项。目前正在开发PhpStorm 2016.2.2.
我通过在项目中的typescript版本全局安装typescript来解决这个问题