在ASP.NET Core Web Application项目中,无法在最新的Visual Studio 2015中修复此错误:
Scripts\app\AppComponent.component.ts(7,14): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
Scripts\app\app.component.ts(7,14): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
Scripts\app\app.module.ts(16,14): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/compile_metadata.d.ts(347,20): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/compile_metadata.d.ts(348,15): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/directive_normalizer.d.ts(19,100): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/directive_normalizer.d.ts(21,74): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/offline_compiler.d.ts(15,26): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/offline_compiler.d.ts(16,38): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/offline_compiler.d.ts(33,124): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/output/output_ast.d.ts(424,63): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/resource_loader.d.ts(13,23): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/runtime_compiler.d.ts(42,49): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/runtime_compiler.d.ts(44,65): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/template_parser/template_parser.d.ts(45,12): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/util.d.ts(36,18): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/util.d.ts(37,46): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/view_compiler/compile_element.d.ts(33,16): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/view_compiler/compile_query.d.ts(24,49): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/view_compiler/compile_view.d.ts(29,18): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/view_compiler/compile_view.d.ts(52,16): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/compiler/src/view_compiler/compile_view.d.ts(54,13): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/application_ref.d.ts(106,67): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/application_ref.d.ts(122,101): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/application_ref.d.ts(148,67): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/application_ref.d.ts(150,101): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(28,16): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/di/reflective_provider.d.ts(88,123): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/di/reflective_provider.d.ts(88,165): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/collection.d.ts(4,9): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/collection.d.ts(5,30): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/collection.d.ts(8,43): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/collection.d.ts(10,23): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/collection.d.ts(11,25): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/linker/compiler.d.ts(53,49): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/linker/compiler.d.ts(61,65): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(28,25): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/core/src/util/lang.d.ts(8,53): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/http/src/headers.d.ts(45,59): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/http/src/url_search_params.d.ts(46,16): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.d.ts(10,23): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts(79,33): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts(97,42): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts(18,37): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/facade/collection.d.ts(4,9): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/facade/collection.d.ts(5,30): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/facade/collection.d.ts(8,43): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/facade/collection.d.ts(10,23): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/@angular/platform-browser/src/facade/collection.d.ts(11,25): error TS2304: Cannot find name 'Map'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/observable/PromiseObservable.d.ts(40,31): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/observable/PromiseObservable.d.ts(41,26): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/operator/toPromise.d.ts(7,59): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/operator/toPromise.d.ts(7,69): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/operator/toPromise.d.ts(9,9): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/operator/toPromise.d.ts(10,26): error TS2304: Cannot find name 'Promise'.
C:/Users/plato/Documents/Visual Studio 2015/Projects/OpenGameList/src/OpenGameListWebApp/node_modules/rxjs/operator/toPromise.d.ts(10,36): error TS2304: Cannot find name 'Promise'.
Solution Explorer:
我的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"
],
"typeRoots": ["./node_modules/@types"],
"type": ["core-js"]
}
我的package.json
:
{
"version": "1.0.0",
"name": "opengamelistwebapp",
"private": true,
"dependencies": {
"@angular/common": "2.0.2",
"@angular/compiler": "2.0.2",
"@angular/core": "2.0.2",
"@angular/http": "2.0.2",
"@angular/platform-browser": "2.0.2",
"@angular/platform-browser-dynamic": "2.0.2",
"@angular/upgrade": "2.0.2",
"core-js": "^2.5.3",
"reflect-metadata": "^0.1.10",
"rxjs": "5.0.0-beta.12",
"systemjs": "^0.20.19",
"zone.js": "^0.6.21",
"@types/core-js": "^0.9.44"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "^2.13.6",
"gulp-uglify": "^2.0.0",
"typescript": "^2.6.2"
}
}
我的gulpfile.js
:
/*
This file in the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/
var gulp = require("gulp"),
gp_clean = require("gulp-clean"),
gp_concat = require("gulp-concat"),
gp_sourcemaps = require("gulp-sourcemaps"),
gp_typescript = require("gulp-typescript"),
gp_uglify = require("gulp-uglify");
var srcPaths = {
app: ["Scripts/app/main.ts", "Scripts/app/**/*.ts"],
js: [
"Scripts/js/**/*js",
"node_modules/core-js/client/shim.min.js",
"node_modules/zone.js/dist/zone.js",
"node_modules/reflect-metadata/Reflect.js",
"node_modules/systemjs/dist/system.src.js",
"node_modules/typescript/lib/typescript.js"
],
js_angular: [
"node_modules/@angular/**"
],
js_rxjs: [
"node_modules/rxjs/**"
]
};
var destPaths = {
app: "wwwroot/app/",
js: "wwwroot/js",
js_angular: "wwwroot/js/@angular/",
js_rxjs: "wwwroot/js/rxjs/"
};
// Compile, minify and create sourcemaps all TypeScript files and place them to wwwroot/app, together with their js.map files.
gulp.task("app",
["app_clean"],
function() {
return gulp.src(srcPaths.app)
.pipe(gp_sourcemaps.init())
.pipe(gp_typescript(require("./tsconfig.json").compileOptions))
.pipe(gp_uglify({
mangle: false
}))
.pipe(gp_sourcemaps.write("/"))
.pipe(gulp.dest(destPaths.app));
});
// Delete wwwroot/app contents
gulp.task("app_clean",
function() {
return gulp.src(destPaths.app + "*", { read: false })
.pipe(gp_clean({ force: true }));
});
// Copy all JS files from extrenal libraries to wwwroot/js
gulp.task("js",
function() {
gulp.src(srcPaths.js_angular).pipe(gulp.dest(destPaths.js_angular));
gulp.src(srcPaths.js_rxjs).pipe(gulp.dest(destPaths.js_rxjs));
return gulp.src(srcPaths.js)
.pipe(gulp.dest(destPaths.js));
});
// Delete wwwroot/js contents
gulp.task("js_clean",
function() {
return gulp.src(destPaths.js + "*", { read: false })
.pipe(gp_clean({ force: true }));
});
// Watch specified files and define what to do upon file changes
gulp.task("watch",
function() {
gulp.watch([srcPaths.app, srcPaths.js], ["app", "js"]);
});
// Global cleanup task
gulp.task("cleanup", ["app_clean", "js_clean"]);
// For Gulp 4
//gulp.task("cleanup", gulp.series("app_clean", "js_clean"));
// Default task
gulp.task("default", ["app", "js", "watch"]);
// For Gulp 4
//gulp.task("default", gulp.series("app", "js", "watch"));
答案 0 :(得分:1)
请求添加
" experimentalDecorators":true
" allowJs":true
进入你的tsconfig.json文件。
{
"compileOnSave": false,
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,
"module": "system",
"moduleResolution": "node",
"noImplicitAny": false,
"noEmitOnError": false,
"removeComments": false,
"target": "es5"
},
"exclude": [
"node_modules",
"wwwroot"
],
"typeRoots": ["./node_modules/@types"],
"type": ["core-js"]
}
答案 1 :(得分:1)
检查tsconfig.json文件是否将内置属性设置为“ Content”而不是“ None”,如果不是,请右键单击tsconfig文件,并将构建操作设置为Content。重新加载项目后,错误应消失
答案 2 :(得分:0)
"compilerOptions": {
"allowJs": true
}
那一行就可以。