Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prettier is removing typescript generic annotation from react class component

I'm trying to make an ErrorBoundary using a class component like this

class ErrorBoundary extends Component<ErrorBoundaryProps,ErrorBoundaryState>

But every time I format it with prettier, the part <ErrorBoundaryProps,ErrorBoundaryState> disappears, I'm not sure if it's prettier or eslint.

Here's my .eslintrc.json

{
  "extends": [
    "next/core-web-vitals",
    "plugin:storybook/recommended"
  ],
  "plugins": ["simple-import-sort"],
  "rules": {
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error"
  },
  "parserOptions": {
    "sourceType": "module",
    "ecmaVersion": "latest"
  }
}
like image 306
E C I N Avatar asked Mar 14 '26 22:03

E C I N


2 Answers

Upgrading to the latest version(version 3.3.3) solved my issue.

like image 179
Arik Chakma Avatar answered Mar 16 '26 11:03

Arik Chakma


for me, I was in (version 3.3.3) so downgrading to the prior version 3.3.2)solved my issue. I dont know why this happens as previous comment says 3.3.3 fixes his problem.

like image 40
Abdurezak Farah Avatar answered Mar 16 '26 12:03

Abdurezak Farah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!