Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio Experimental support for decorators is a feature that is subject to change in a future release error

I have common-helper.ts in my angular 6 app and i take "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning". Is my naming convention is wrong? Because when i remove "-" and change to file name to "commonhelper.ts" the error is fixing. And when i add tsconfig.json file "experimentalDecorators": true, error isn't fixing.

@Injectable({
  providedIn: 'root'
})
export class CommonHelper {

  constructor() { }

  }
}

my tsconfig.json file

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    //"emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}
like image 373
realist Avatar asked Nov 27 '22 20:11

realist


2 Answers

In tsconfig.json:

"compilerOptions": {
    "experimentalDecorators": true,
    "allowJs": true,
...
}

Which is what every other comment/post I've scoured the internet on the subject says... and kept me frustrated... but I figured out what made the difference is:

PUT THIS AT THE VERY TOP OF COMPILER OPTIONS BEFORE ANYTHING ELSE

So something is messing it up due to ordering. Hope that helps? Put the experimentalDecorators and allowJS parameters at the very top of your object before anything else.

like image 164
FiferJanis Avatar answered Nov 30 '22 10:11

FiferJanis


This SO answer worked for me.

Modify your .csproj file to add: <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>

like image 34
Victor Ian Avatar answered Nov 30 '22 08:11

Victor Ian