加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

使用TypeScript装饰器会导致错误

发布时间:2020-12-15 19:51:14 所属栏目:asp.Net 来源:网络整理
导读:我在新的ASP.NET核心项目类型中使用TypeScript. 我们积极使用decorators. 不幸的是,这会导致VS2015输出中的大量错误: Error TS1219 Experimental support for decorators is a feature that is subject to change in a future release.Specify '--experimen
我在新的ASP.NET核心项目类型中使用TypeScript.

我们积极使用decorators.

不幸的是,这会导致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:documentsvisual studio 2015ProjectsWebApplication2srcWebApplication2wwwrootsourcesapp.ts 9   Active

这很容易摆脱这些错误消息in regular ASP.NET projects修改* .csproj文件.

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

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

你可能会找到最简单的项目来重现问题in sample github rep

解决方法

>右键单击您的项目>添加>新物品.
>从中挑选客户端
左手菜单.
>添加新的TypeScript JSON配置文件.将其保留为tsconfig.json的默认名称.
>打开tsconfig.json.在complierOptions部分中,添加“experimentalDecorators”:true.
>从“排除”部分删除“wwwroot”.
>建立和享受.

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读