Angular 5.0.2在-prod上混淆了PhpStorm + ERROR中的Promise类定义

时间:2017-11-17 19:11:13

标签: angular typescript phpstorm config webstorm

我有一个Angular应用程序并使用PhpStorm。 在更新到Angular 5之后(通过npm等...)我有一些令人困惑的问题。

所有Promise<MyClass>都被标记为错误原因&#34;承诺不是通用的&#34;

在检查Promise类时,我可以在&#34; index.d.ts&#34;中的接口和类之间进行选择。 (在Promises_es6和@jquery的node_modules中)两者都是通用的。

我的配置中显然有错误。有人能帮助我找到它吗?

以下是配置:

的package.json:

{
  "name": "my-site",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.1",
    "@angular/animations": "^5.0.1",
    "@angular/cdk": "^5.0.0-rc0",
    "@angular/common": "^5.0.1",
    "@angular/compiler": "^5.0.1",
    "@angular/core": "^5.0.1",
    "@angular/forms": "^5.0.1",
    "@angular/http": "^5.0.1",
    "@angular/material": "^5.0.0-rc0",
    "@angular/platform-browser": "^5.0.1",
    "@angular/platform-browser-dynamic": "^5.0.1",
    "@angular/router": "^5.0.1",
    "@types/es6-promise": "0.0.33",
    "ap-angular2-fullcalendar": "^1.3.5",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.2.1",
    "material-design-icons": "^3.0.1",
    "rxjs": "^5.4.1",
    "zone.js": "^0.8.17"
  },
  "devDependencies": {
    "@angular/cli": "^1.5.2",
    "@angular/compiler-cli": "^5.0.1",
    "@angular/language-service": "^5.0.1",
    "@types/jasmine": "~2.6.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~8.0.51",
    "codelyzer": "~4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.2.0",
    "ts-node": "~3.3.0",
    "tslint": "~5.8.0",
    "typescript": "^2.4.2",
    "uglifyjs-webpack-plugin": "^1.0.1"
  }
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "ESNext", 
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

enter image description here

编辑:承诺导致错误--prod build (dev build works)

构建后--prod模式。一切都运行良好。在访问该站点时,屏幕保持空白,并且此错误出现在控制台中:

main.3933c1a670523b7e59b4.bundle.js:1 ERROR TypeError: Cannot read property '_moduleDoBootstrap' of undefined
    at e.donePromise.then (main.3933c1a670523b7e59b4.bundle.js:1)
    at e.invoke (polyfills.20052382fb9ecf29cee5.bundle.js:1)
    at Object.onInvoke (main.3933c1a670523b7e59b4.bundle.js:1)
    at e.invoke (polyfills.20052382fb9ecf29cee5.bundle.js:1)
    at r.run (polyfills.20052382fb9ecf29cee5.bundle.js:1)
    at polyfills.20052382fb9ecf29cee5.bundle.js:1
    at e.invokeTask (polyfills.20052382fb9ecf29cee5.bundle.js:1)
    at Object.onInvokeTask (main.3933c1a670523b7e59b4.bundle.js:1)
    at e.invokeTask (polyfills.20052382fb9ecf29cee5.bundle.js:1)
    at r.runTask (polyfills.20052382fb9ecf29cee5.bundle.js:1)
(anonymous) @ main.3933c1a670523b7e59b4.bundle.js:1
handleError @ main.3933c1a670523b7e59b4.bundle.js:1
t.runOutsideAngular @ main.3933c1a670523b7e59b4.bundle.js:1
e.invoke @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.run @ polyfills.20052382fb9ecf29cee5.bundle.js:1
runOutsideAngular @ main.3933c1a670523b7e59b4.bundle.js:1
n.catch.n @ main.3933c1a670523b7e59b4.bundle.js:1
e.invoke @ polyfills.20052382fb9ecf29cee5.bundle.js:1
onInvoke @ main.3933c1a670523b7e59b4.bundle.js:1
e.invoke @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.run @ polyfills.20052382fb9ecf29cee5.bundle.js:1
(anonymous) @ polyfills.20052382fb9ecf29cee5.bundle.js:1
e.invokeTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
onInvokeTask @ main.3933c1a670523b7e59b4.bundle.js:1
e.invokeTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.runTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
o @ polyfills.20052382fb9ecf29cee5.bundle.js:1
Promise resolved (async)
r @ polyfills.20052382fb9ecf29cee5.bundle.js:1
e.scheduleTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
onScheduleTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
e.scheduleTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.scheduleTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.scheduleMicroTask @ polyfills.20052382fb9ecf29cee5.bundle.js:1
c @ polyfills.20052382fb9ecf29cee5.bundle.js:1
e.then @ polyfills.20052382fb9ecf29cee5.bundle.js:1
appInitializer @ main.3933c1a670523b7e59b4.bundle.js:1
runInitializers @ main.3933c1a670523b7e59b4.bundle.js:1
n @ main.3933c1a670523b7e59b4.bundle.js:1
(anonymous) @ main.3933c1a670523b7e59b4.bundle.js:1
n.run @ main.3933c1a670523b7e59b4.bundle.js:1
e.invoke @ polyfills.20052382fb9ecf29cee5.bundle.js:1
onInvoke @ main.3933c1a670523b7e59b4.bundle.js:1
e.invoke @ polyfills.20052382fb9ecf29cee5.bundle.js:1
r.run @ polyfills.20052382fb9ecf29cee5.bundle.js:1
run @ main.3933c1a670523b7e59b4.bundle.js:1
bootstrapModuleFactory @ main.3933c1a670523b7e59b4.bundle.js:1
cDNt @ main.3933c1a670523b7e59b4.bundle.js:1
n @ inline.81a18cab7f77e5e3b05a.bundle.js:1
0 @ main.3933c1a670523b7e59b4.bundle.js:1
n @ inline.81a18cab7f77e5e3b05a.bundle.js:1
window.webpackJsonp @ inline.81a18cab7f77e5e3b05a.bundle.js:1
(anonymous) @ main.3933c1a670523b7e59b4.bundle.js:1
main.3933c1a670523b7e59b4.bundle.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read property '_moduleDoBootstrap' of undefined
TypeError: Cannot read property '_moduleDoBootstrap' of undefined
    at e.donePromise.then (main.3933c1a670523b7e59b4.bundle.js:1)
...

1 个答案:

答案 0 :(得分:0)

由于这个问题似乎没有好主意,而角度5仍然会产生很多问题,我重置为4.4.4版本,一切都恢复顺利。