在我的typings.d.ts上出现此错误。文件
错误TS2403:后续变量声明必须具有相同的类型。变量'模块'必须有类型' NodeModule',但这里有类型' {id:string}'。
declare var module: {
id: string;
};
declare module '*';
declare module 'clappr';
declare module 'c3';
declare module 'd3';
为什么?无论如何要解决它?
感谢您的反馈
答案 0 :(得分:0)
很久以前...
对我来说,更新Angular应用时,ng serve的错误是:
“ node_modules/@types/node/index.d.ts(117,13)中的错误:错误TS2403:后续变量声明必须具有相同的类型。变量'module'的类型必须为'{id:string; }',但此处的类型为'NodeModule'“
所以我转到node_modules/@types/node/index.d.ts(117,13)并手动执行此操作:
//declare var module: NodeModule; <---- old text
declare var module: { id: string; }; <--- new text
现在可以编译...但是我要测试该应用...
ng -v:
Angular CLI: 6.0.8
Node: 8.11.3
OS: darwin x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.1
typescript 2.7.2
我的package.json是:
{
"name": "client",
"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.5",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.1.2",
"@ngui/map": "^0.18.6",
"bootstrap": "^3.3.7",
"core-js": "^2.5.7",
"ng2-file-upload": "^1.3.0",
"rxjs": "^5.5.12",
"rxjs-compat": "^6.3.2",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "^6.2.3",
"@angular/compiler-cli": "^5.0.0",
"@types/googlemaps": "^3.30.13",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.117",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.1",
"ts-node": "~2.0.0",
"tslint": "^5.0.0",
"typescript": "^2.9.2"
}
}