我正在使用Visual Studio 2017与Asp.Net核心WebApi后端开发Angular 2应用程序。我正在关注ASP.NET Core和Angular 2 Book,作者是Valerio De Sanctis。 一切工作正常,直到我添加@角/形式包。当我开始任务运行有几个误区:Angular 2 Typescript编译错误
[00:28:42] Starting 'app_clean'...
[00:28:42] Starting 'js'...
[00:28:42] Starting 'watch'...
[00:28:42] Finished 'watch' after 27 ms
[00:28:42] Finished 'app_clean' after 77 ms
[00:28:42] Starting 'app'...
C:/Users/Phoenix/Desktop/Angular 2 курс/CollectionsWorkAngular3/src/CollectionsWorkAngular/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2693: 'Map' only refers to a type, but is being used as a value here.
C:/Users/Phoenix/Desktop/Angular 2 курс/CollectionsWorkAngular3/src/CollectionsWorkAngular/node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2693: 'Set' only refers to a type, but is being used as a value here.
C:/Users/Phoenix/Desktop/Angular 2 курс/CollectionsWorkAngular3/src/CollectionsWorkAngular/node_modules/rxjs/Observable.d.ts(69,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
C:/Users/Phoenix/Desktop/Angular 2 курс/CollectionsWorkAngular3/src/CollectionsWorkAngular/typings/globals/core-js/index.d.ts(2083,41): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'.
[00:28:45] TypeScript: 80 semantic errors
[00:28:45] TypeScript: emit succeeded (with errors)
{ "version": "1.0.0", "name": "collectionswork", "private": true, "dependencies": { "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", "@angular/core": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", "@angular/platform-browser-dynamic": "2.4.8", "@angular/upgrade": "2.4.8", "@angular/forms": "2.4.8", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.2.0", "systemjs": "^0.19.37", "typings": "^2.1.0", "zone.js": "^0.7.2" }, "devDependencies": { "gulp": "^3.9.1", "gulp-clean": "^0.3.2", "gulp-concat": "^2.6.0", "gulp-sourcemaps": "^1.6.0", "gulp-typescript": "^3.1.5", "gulp-uglify": "^2.0.0", "typescript": "^2.0.0" }, "scripts": { "postinstall": "typings install dt~core-js --global" } }
这里是我的tsconfig.json:
{ "compileOnSave": false, "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "system", "moduleResolution": "node", "noImplicitAny": false, "noEmitOnError": false, "removeComments": false, "target": "es5" }, "exclude": [ "node_modules", "wwwroot" ] }
当我更改'“脚本”:{“postinstall”:“typings install core-js --global”}'并点击保存,我在npm输出中出现错误: –
以下更改正在为我工作。 ''scripts“:{”postinstall“:”typings install dt〜core-js --global“} to''scripts':{}' 您是否忘记删除逗号(**,* *)在** scripts **标签前面。 – neojustice
好的!我会尝试。在你的回答开始时,你注意到这行''typings install core-js --global',你能解释一下我应该怎么做吗?我很抱歉这样的问题。 –