22
votes

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

3
Have you closed VS and opened it again? It might need to be restarted for the intelisense to notice the change. - Igor
And on a side note the angular is for angular 2x, angularjs is for angularjs 1.x. - Igor
I tried closing and opening the project but it gave me the same error again - LearningPal

3 Answers

49
votes

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.

19
votes

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

0
votes

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>