繁体   English   中英

使用TypeScript装饰器会导致错误

[英]Using of TypeScript decorators caused errors

我在新的ASP.NET核心项目类型中使用TypeScript。

我们积极使用装饰器

不幸的是,这会导致VS2015输出中的大量错误:

Error   TS1219  Experimental support for decorators is a feature that is subject to change in a future release.
Specify '--experimentalDecorators' to remove this warning.  
WebApplication2 d:\documents\visual studio 2015\Projects\WebApplication2\src\WebApplication2\wwwroot\sources\app.ts 9   Active

修改*.csproj文件的常规ASP.NET项目中摆脱这些错误消息非常简单。

但ASP.NET Core项目不使用.csproj ,而是使用.xproj

那么,如何在ASP.NET Core项目中允许VS2015中的实验性TypeScript装饰器支持?


您可以找到最简单的项目,它可以在github示例代码中重现问题

  1. 右键单击项目> Add > New Item
  2. 从左侧菜单中选择Client-side
  3. 添加新的TypeScript JSON Configuration File 将其保留为tsconfig.json的默认名称。
  4. 打开tsconfig.json complierOptions部分中,添加"experimentalDecorators": true
  5. "exclude"部分删除"wwwroot"
  6. 建立和享受。

这是我的tsconfig.json文件的完整性:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "experimentalDecorators": true
  },
  "exclude": [
    "node_modules"
  ]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM