当前位置: 代码迷 >> JavaScript >> 在我的Angular 6项目中,我将GOjs库放入了TS编译错误
  详细解决方案

在我的Angular 6项目中,我将GOjs库放入了TS编译错误

热度:18   发布时间:2023-06-05 10:15:09.0

我刚刚将Gojs包含在当前的角度项目中。

我遵循的步骤

npm install gojs --save

在我的应用程序组件中,我刚刚导入了gojs

import * as go from 'gojs';

之后,当我运行ng服务/构建时,我遇到了以下错误。

RROR in node_modules/gojs/release/go.d.ts(14239,27): error TS1005: ')' expected.
node_modules/gojs/release/go.d.ts(14239,45): error TS1005: ',' expected.
node_modules/gojs/release/go.d.ts(14239,68): error TS1005: ',' expected.
node_modules/gojs/release/go.d.ts(14240,16): error TS1005: ',' expected.
node_modules/gojs/release/go.d.ts(14240,38): error TS1005: ',' expected.
node_modules/gojs/release/go.d.ts(14241,43): error TS1005: ',' expected.
node_modules/gojs/release/go.d.ts(14242,5): error TS1138: Parameter declaration expected.
node_modules/gojs/release/go.d.ts(14242,7): error TS1128: Declaration or statement expected.
node_modules/gojs/release/go.d.ts(14242,11): error TS1128: Declaration or statement expected.
node_modules/gojs/release/go.d.ts(14242,12): error TS1128: Declaration or statement expected.
node_modules/gojs/release/go.d.ts(14242,14): 

Pacakage.json

"@angular/cli": "~6.0.3",
"@angular/compiler-cli": "~6.0.2",
"@angular/language-service": "~6.0.2",

"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",

"gulp": "^4.0.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "~0.2.2",
"minimist": "~1.2.0",
"ng-packagr": "~3.0.0-rc.2",
"protractor": "^5.4.1",
"ts-node": "~5.0.1",
"tsickle": ">=0.25.5",
"tslib": "~1.7.1",
"tslint": "~5.9.1",
"typescript": "^2.7.2"

您需要升级TypeScript版本。
go.d.ts文件需要v2.8。
要升级当前的TypeScript Verison,请执行以下操作: npm install -g typescript@latest

谢谢@walter Northwoods,

我刚刚将GOJS 2. *降级为1.8 *

npm install gojs@1.8.34 

解决了问题。