20

I have created a .Net Core project with AngularJS in Visual Studio 2017 however when I am trying to create a service, I am getting an error as

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option `to remove this warning.

I have checked several links such as editing tsconfig.json following links such as link1 and link2

Now my tsconfig.json looks like below

    {
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "allowJs": true,
    "noEmit": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include": [
    "app/**/*"
  ],
  "files": [], //add a "files" array (in my case empty)
  "exclude": [
    "node_modules"
  ],
  "typeAcquisition": {
    "enable": true // helps fuel better js intellisense
  }
}

But I still see the error and I am clueless now.

enter image description here

Igor
  • 55,253
  • 10
  • 80
  • 149
LearningPal
  • 540
  • 2
  • 8
  • 25
  • 2
    Have you closed VS and opened it again? It might need to be restarted for the intelisense to notice the change. – Igor Aug 18 '18 at 10:33
  • 1
    And on a side note the [tag:angular] is for angular 2x, [tag:angularjs] is for angularjs 1.x. – Igor Aug 18 '18 at 10:34
  • I tried closing and opening the project but it gave me the same error again – LearningPal Aug 18 '18 at 11:34

3 Answers3

45

add

<PropertyGroup>
<TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators></PropertyGroup>

in .csproj file of your project as it will be given precedence over tsconfig.json file and the restart visual studio and the error is no longer there.

Haiku
  • 466
  • 1
  • 5
  • 3
  • 1
    This still didn't fix the issue for me, even after restarting VS. – Ageonix Jan 02 '19 at 18:59
  • @Ageonix same here. I've tried all the suggested fixes. Bubkes. – MrBoJangles Feb 08 '19 at 21:25
  • This seemed to fix the issue this time. Someone commented out this piece and I put it back in and it seemed to work. Now I need to find out why this was commented out in the first place. – MrBoJangles Mar 13 '19 at 18:30
  • The underline in the editor went away but its still coming up in the Error List. Anyway to clear those warnings? – Donny V. Jan 17 '20 at 16:54
18

Same issue here and it was driving me mad.
Add in .csproj file of your project

<ItemGroup>
    <Content Include="ClientApp\tsconfig.json">
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

https://github.com/Microsoft/TypeScript/issues/25823

Elanor-L
  • 221
  • 3
  • 6
0

In your .csproj, add the below PropertyGroup to suppress the experimentalDecorator error (1219 at time of this writing). You may need to reload your project afterwards. This also works for VS 2019.

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <NoWarn>1219;</NoWarn>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
        <NoWarn>1219;</NoWarn>
    </PropertyGroup>
jGroot
  • 542
  • 3
  • 9