简体   繁体   中英

Class is using Angular features but is not decorated with Typescript 4.8.2

I'm getting this "Class is using Angular features but is not decorated" error on all my components on Angular since I upgraded Typescript to 4.8.2.

This error shows on the export class name of each component.

Has anyone expericenced this same issue?

@Component({
  selector: "app-members",
  templateUrl: "./members.component.html",
  styleUrls: ["./members.component.scss"]
})
export class MembersComponent implements OnInit {...

In this example the "MembersComponent" throws the error.

My tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "noUnusedLocals": false,
    "target": "ES2021",
    "forceConsistentCasingInFileNames": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "ES2021.String",
      "ES2021",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "preserveWhitespaces": true,
    "strictTemplates": true
  }
}

I had the exact same issue, the code still compiles and runs ok, but for now I have downgraded typescript to 4.7.4, ro prevent annoying errors in editor.. and also keeping an eye out for next version higher than 4.8.2 to see if any fix

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM