簡體   English   中英

Class 正在使用 Angular 功能但未使用 Typescript 4.8.2 進行裝飾

[英]Class is using Angular features but is not decorated with Typescript 4.8.2

自從我將 Typescript 升級到 4.8.2 以來,我在 Angular 上的所有組件上都出現了“類正在使用 Angular 功能但未裝飾”錯誤。

此錯誤顯示在每個組件的導出 class 名稱上。

有沒有人遇到過同樣的問題?

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

在此示例中,“MembersComponent”會引發錯誤。

我的 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
  }
}

我遇到了完全相同的問題,代碼仍然可以編譯和運行,但現在我已將 typescript 降級到 4.7.4,防止編輯器中出現惱人的錯誤.. 並留意高於 4.8.2 的下一個版本看看有沒有修復

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM