Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using of TypeScript decorators caused errors

I'm using TypeScript in new ASP.NET core project type.

We actively use decorators.

Unfortunately, that causes lot of errors in VS2015 output:

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

That is quite simple to get rid of these error messages in regular ASP.NET projects modifying *.csproj file.

But ASP.NET Core project does not use .csproj, it uses .xproj instead.

So, how to allow experimental TypeScript decorators support in VS2015 in ASP.NET Core project?


You may find simplest project which reproduces the problem in sample github rep

like image 249
Andrey Kuleshov Avatar asked Oct 19 '22 15:10

Andrey Kuleshov


1 Answers

  1. Right click on your project > Add > New Item.
  2. Pick Client-side from the left hand menu.
  3. Add a new TypeScript JSON Configuration File. Leave it as the default name of tsconfig.json.
  4. Open tsconfig.json. In the complierOptions section, add "experimentalDecorators": true.
  5. Remove "wwwroot" from the "exclude" section.
  6. Build and enjoy.

Here is my tsconfig.json file for completeness:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "experimentalDecorators": true
  },
  "exclude": [
    "node_modules"
  ]
}
like image 52
Jamie Dunstan Avatar answered Nov 15 '22 06:11

Jamie Dunstan