错误TS2563:包含的函数或模块主体太大,无法进行控制流分析

时间:2019-05-24 19:27:53

标签: angular typescript angular6 angular7

我在angular项目中升级了package.json。从Angular 6迁移到了7。在尝试构建时,在控制台中看到此错误。

错误TS2563:包含的函数或模块主体太大,无法进行控制流分析。

这是我的新package.json

{
  "name": "e-case-prototype",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng serve --proxy-config proxy.conf.json --source-map=false",
    "build": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build",
    "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod",
    "build-prod-aot-disabled": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod --aot false --build-optimizer false",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "^0.13.9",
    "@angular/animations": "7.2.15",
    "@angular/cdk": "7.3.7",
    "@angular/common": "7.2.15",
    "@angular/compiler": "7.2.15",
    "@angular/core": "7.2.15",
    "@angular/flex-layout": "^7.0.0-beta.24",
    "@angular/forms": "7.2.15",
    "@angular/http": "7.2.15",
    "@angular/material": "7.3.7",
    "@angular/platform-browser": "7.2.15",
    "@angular/platform-browser-dynamic": "7.2.15",
    "@angular/router": "7.2.15",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-charts": "11.1.0",
    "@types/moment-timezone": "^0.5.12",
    "angular-calendar": "^0.27.8",
    "angular-draggable-droppable": "^4.3.0",
    "angular-in-memory-web-api": "0.8.0",
    "angular-resizable-element": "^3.2.4",
    "chart.js": "^2.8.0",
    "classlist.js": "^1.1.20150312",
    "codelyzer": "^5.0.1",
    "core-js": "^2.5.7",
    "date-fns": "^1.30.1",
    "hammerjs": "2.0.8",
    "intl": "1.2.5",
    "jquery": "^3.4.1",
    "luxon": "^1.15.0",
    "moment": "2.24.0",
    "moment-timezone": "^0.5.25",
    "ng-dynamic-component": "^4.0.3",
    "ng2-charts": "2.2.3",
    "ng2-dnd": "5.0.2",
    "ngx-captcha": "^6.4.0",
    "ngx-color-picker": "7.5.0",
    "ngx-cookie-service": "2.2.0",
    "ngx-material-timepicker": "^3.1.0",
    "ngx-quill": "^5.1.0",
    "npm-check": "^5.9.0",
    "perfect-scrollbar": "1.4.0",
    "prismjs": "1.16.0",
    "quill": "^1.3.6",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.2",
    "systemjs": "^3.1.6",
    "tslib": "^1.9.3",
    "web-animations-js": "^2.3.1",
    "zone.js": "0.9.1"
  },
  "devDependencies": {
    "@angular/cli": "7.3.9",
    "@angular/compiler-cli": "7.2.15",
    "@angularclass/hmr": "2.1.3",
    "@types/jasmine": "3.3.12",
    "@types/jasminewd2": "2.0.6",
    "@types/node": "12.0.2",
    "jasmine-core": "3.4.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.5",
    "karma-jasmine": "2.0.1",
    "karma-jasmine-html-reporter": "1.4.2",
    "protractor": "5.4.2",
    "ts-node": "8.1.0",
    "tslint": "5.16.0",
    "typescript": "3.1.6",
    "webpack-bundle-analyzer": "3.3.2"
  }
}

这是正在运行的旧package.json

{
  "name": "e-case-prototype",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng serve --proxy-config proxy.conf.json --source-map=false",
    "build": "ng build",
    "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod",
    "build-prod-aot-disabled": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod --aot false --build-optimizer false",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "^0.6.3",
    "@angular/animations": "6.0.2",
    "@angular/cdk": "6.0.2",
    "@angular/common": "6.0.2",
    "@angular/compiler": "6.0.2",
    "@angular/core": "6.0.2",
    "@angular/flex-layout": "5.0.0-beta.14",
    "@angular/forms": "6.0.2",
    "@angular/http": "6.0.2",
    "@angular/material": "6.0.2",
    "@angular/platform-browser": "6.0.2",
    "@angular/platform-browser-dynamic": "6.0.2",
    "@angular/router": "6.0.2",
    "@ngx-translate/core": "^10.0.1",
    "@ngx-translate/http-loader": "^3.0.1",
    "@swimlane/ngx-charts": "8.0.1",
    "@types/moment-timezone": "^0.5.11",
    "angular-calendar": "0.25.2",
    "angular-draggable-droppable": "^3.0.0",
    "angular-in-memory-web-api": "0.6.0",
    "angular-resizable-element": "^3.0.0",
    "classlist.js": "^1.1.20150312",
    "codelyzer": "^4.3.0",
    "core-js": "2.5.6",
    "hammerjs": "2.0.8",
    "intl": "1.2.5",
    "jquery": "^3.3.1",
    "moment": "2.22.1",
    "moment-timezone": "^0.5.23",
    "ng-dynamic-component": "^3.0.0",
    "ng2-charts": "1.6.0",
    "ng2-dnd": "5.0.2",
    "ngx-captcha": "^5.0.3",
    "ngx-color-picker": "6.1.0",
    "ngx-cookie-service": "1.0.10",
    "ngx-material-timepicker": "^2.13.0",
    "ngx-quill": "^3.1.0",
    "npm-check": "^5.7.1",
    "perfect-scrollbar": "1.3.0",
    "prismjs": "1.14.0",
    "quill": "^1.3.6",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "systemjs": "^0.21.4",
    "tslib": "^1.9.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "6.0.3",
    "@angular/compiler-cli": "6.0.2",
    "@angularclass/hmr": "2.1.3",
    "@types/jasmine": "2.8.7",
    "@types/jasminewd2": "2.0.3",
    "@types/node": "10.1.2",
    "jasmine-core": "3.1.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "2.0.2",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.0",
    "karma-jasmine": "1.1.2",
    "karma-jasmine-html-reporter": "1.1.0",
    "protractor": "5.3.2",
    "ts-node": "6.0.3",
    "tslint": "5.10.0",
    "typescript": "^2.7.2",
    "webpack-bundle-analyzer": "2.13.0"
  }
}

我已经尝试升级到其他打字稿版本。我受到Angular的限制,因为该版本必须在3.1.1和3.3之间

该代码在^ 2.7.2的早期打字稿版本上进行编译

1 个答案:

答案 0 :(得分:0)

此功能有多大?根据{{​​3}},在函数中包含超过10,000个节点后,预计会出现此错误。

==== tests/cases/compiler/largeControlFlowGraph.ts (1 errors) ====
    // The control flow graph for the following statement block is 10000 nodes deep. Check that
    // we gracefully handle this, possibly by issuing an error.
    const data = [];
    ~~~~~
!!! error TS2563: The containing function or module body is too large for control flow analysis.
data[0] = 0;
data[0] = 0;
data[0] = 0;

//they do this 10000 more times...

data[0] = 0;
data[0] = 0;