IntelliJ无法识别基本Ionic2项目中的Promise类型

eza*_*ain 8 intellij-idea typescript ionic2

我正在开发一个Ionic 2 rc.1应用程序,我使用的是idea 2016.2.4.

项目运行正常,但IDE无法识别Promise的typescript定义,因为它似乎"不包含在tsconfig.json中"

检查错误是: Corresponding file is not included in tsconfig.json

我的tsconfig.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
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我从"exclude"块中删除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"
  ]
}
Run Code Online (Sandbox Code Playgroud)

有人知道如何解决这个问题吗?

谢谢

eza*_*ain 6

最后,我通过一种解决方法解决了我的问题.

它解决了所有不能将es2015类型识别到IDE中的问题:

先决条件:将Idea IntelliJ升级到> 2016.2.4

  1. 首先确保typescript安装为全局.

    npm install -g typescript

  2. 在设置中设置上面安装的打字稿版本

    在"首选项">"语言和框架">"TypeScript">"TypeScript版本">"编辑"中

    设置npm包的路径.就我而言:/usr/local/lib/node_modules/typescript/lib

  3. 最后在编译器选项中放置选项Set options,手动实例使用tsconfig.json

  4. 在某些情况下,您应该激活选项使用TypeScript服务(实验)

自动填充功能正常,检查员不再出现问题.