在诸如“Object.assign”和“Promise<any>”之类的事情上突出显示错误

Getting error-highlighting on things like `Object.assign` and `Promise<any>`

您好,在使用 WebStorm 2016.2.2 时,我在 tsconfig 中支持 "lib" 属性 时遇到问题。

我已经尝试在 IDE 首选项 (Preferences -> Languages & Frameworks -> TypeScript) 中编辑 TypeScript 版本并指向全局安装的 TypeScript 2.0 版本,但我仍然在某些事情上突出显示错误像 Object.assignPromise<any>

我已经多次重启 IDE,但似乎没有任何变化,关于如何修复或调试这个问题有什么想法吗?

//tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "noEmitHelpers": true,
    "strictNullChecks": false,
    "baseUrl": "./src",
    "paths": {
        "core": ["app/core"],
        "reactive": ["app/reactive"],
        "models": ["app/models"],
        "services": ["app/services"]
    },
    "lib": [
      "dom",
      "es6"
    ],
    "types": [
      "hammerjs",
      "jasmine",
      "node",
      "protractor",
      "selenium-webdriver",
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}

您指定:

"target": "es5"

因此编译器将使用常规 lib.d.ts and not the lib.es6.d.ts 编译它,因此缺少 ES6 功能,例如 Object.assignPromise 等。

改为

"target": "es6"

应该没问题。