gpt4 book ai didi

angular - 错误 TS2563 : The containing function or module body is too large for control flow analysis

转载 作者:太空狗 更新时间:2023-10-29 19:31:40 25 4
gpt4 key购买 nike

我在 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"
}
}

我已经尝试升级到不同的 typescript 版本。我受到 Angular 的限制,因为版本必须在 3.1.1 和 3.3 之间

代码是在以前的 ^2.7.2 typescript 版本上编译的

最佳答案

这个函数有多大?根据this reference file in the TypeScript source code在函数中包含超过 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;

关于angular - 错误 TS2563 : The containing function or module body is too large for control flow analysis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56298571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com