在运行ng test命令时出现这些错误。我使用Angular-Cli创建了这个项目。 Ng服务正常运行没有任何错误,但是ng测试没有正常运行。
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts (32,16): Cannot find name 'M
ap'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/di/reflective_provider.d.ts (87,123): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/rxjs/Observable.d.ts (58,60): 'Promise' only refers to a type, but is being used as a value here.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts (15,48): Cannot find name 'Iterable
'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts (23,18): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts (28,32): Cannot find name 'I
terable'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts (24,16): Cannot find name 'M
ap'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/core/src/di/reflective_provider.d.ts (87,165): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/common/src/directives/ng_class.d.ts (48,34): Cannot find name 'Set'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/router/src/router_outlet_context.d.ts (42,28): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/router/src/router_outlet_context.d.ts (43,34): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/rxjs/operator/toPromise.d.ts (3,79): 'Promise' only refers to a type, but is being used as a value h
ere.
ERROR in D:/Working/TestAngular4/node_modules/@angular/http/src/headers.d.ts (52,71): Cannot find name 'Map'.
ERROR in D:/Working/TestAngular4/node_modules/@angular/http/src/url_search_params.d.ts (46,16): Cannot find name 'Map'.
Even I changes the auto created target ES5 to ES6.
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
{
"name": "ccw-client-app",
"version": "0.0.0",
"license": "Copyright, 2017",
"scripts": {
"ng": "ng",
"start-ng": "ng serve",
"start": "node src/server/index.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"sme": "./node_modules/.bin/source-map-explorer"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.3.6",
"@angular/cdk": "^2.0.0-beta.10",
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/flex-layout": "^2.0.0-beta.9",
"@angular/forms": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/material": "^2.0.0-beta.10",
"@angular/platform-browser": "^4.3.6",
"@angular/platform-browser-dynamic": "^4.3.6",
"@angular/router": "^4.3.6",
"": "^4.0.3",
"": "^7.2.0",
"": "^1.0.2",
"angular2-logger": "^0.6.0",
"core-js": "^2.4.1",
"devextreme": "^17.1.6",
"devextreme-angular": "^17.1.6",
"hammerjs": "^2.0.8",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.3.2",
"@angular/compiler-cli": "^4.3.6",
"@angular/language-service": "^4.3.6",
"": "^4.0.0",
"": "~2.5.53",
"": "~2.0.2",
"": "~6.0.60",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"phantomjs-prebuilt": "^2.1.15",
"protractor": "~5.1.2",
"source-map-explorer": "^1.4.0",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
Please help.
答案 0 :(得分:0)
尝试将tsconfig中的目标属性更改为ES5