0

Created a brand new Angular + .net core application through VS2022. First time running, and all works perfectly.

Added a simple file :-

 import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
class HeroService { }

and we are presented with the following error:-

TS1219 Build:Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.

we have

"experimentalDecorators": true,

our tsconfig file :-

{
  "compileOnSave": false,
  "compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"allowJs": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "es2020",
"lib": [
  "es2018",
  "dom"
]
    },

  "angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
  }
 }

why would we still receive this error?

Simon
  • 1,412
  • 4
  • 20
  • 48
  • did you add it using `ng generate service hero`? – Andy Jul 06 '23 at 15:50
  • @Andy i didnt, no. Just did 'Add Type script' - to note. if i remove Injectable, it runs perfectly fine. As soon as it added, it breaks. I think its something to do with how visual studio is building the app, but i cant figure out the issue... – Simon Jul 07 '23 at 06:53
  • remove that file you created, and use the command i posted above and try again. Creating a service is a little more complicated than just adding a TS file. There are other things that need to be wired up. I use the same project in VS2022 and have no issues. Read [this](https://angular.io/tutorial/tour-of-heroes/toh-pt4#create-the-heroservice) for more info. – Andy Jul 07 '23 at 13:18

0 Answers0