Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript 4.9 satisfies operator causes error #204

Open
sublimator opened this issue Jan 23, 2023 · 5 comments
Open

TypeScript 4.9 satisfies operator causes error #204

sublimator opened this issue Jan 23, 2023 · 5 comments

Comments

@sublimator
Copy link

See also: prettier/prettier#13951

@sublimator
Copy link
Author

@trivago ?

@reiss-d
Copy link

reiss-d commented Feb 5, 2023

For anyone using pnpm here's a temporary fix I'm using.

In package.json (if using a monorepo this is the root package.json) add:

"pnpm": {
      "overrides": {
         "@trivago/prettier-plugin-sort-imports>@babel/core": "7.20.12",
         "@trivago/prettier-plugin-sort-imports>@babel/parser": "7.20.15",
         "@trivago/prettier-plugin-sort-imports>@babel/traverse": "7.20.13"
      }
},

In your prettier config add:

"overrides": [
      {
         "files": ["*.ts", "*.tsx"],
         "options": {
            "parser": "typescript",
            "importOrderParserPlugins": ["typescript", "jsx"]
         }
      }
   ]

@sublimator
Copy link
Author

Thanks

@mon-jai
Copy link

mon-jai commented Feb 15, 2023

The npm version of @reiss-d's fix:

{
  "overrides": {
    "@trivago/prettier-plugin-sort-imports": {
      "@babel/core": "^7.20.12",
      "@babel/parser": "$@babel/core",
      "@babel/traverse": "$@babel/core"
    }
  }
}

Because of a bug of npm, npm install won't work by just adding these lines to package.json.

You will need to either remove package-lock.json and node_modules before running npm install, or run npm update instead.


Edit: I got prettier worked successfully without modifying .prettierrc.

@OliverJAsh
Copy link

This sort of issue happens every time TypeScript introduces new syntax. For example, we also had this problem back when TypeScript added Instantiation Expressions in v4.7.

To prevent these sort of issues from re-occurring I believe the following issue should be addressed: #141

johnvictorfs added a commit to jornadayu/yu-open-lib that referenced this issue Mar 27, 2023
Relevant issue for the package.json changes for the '@trivago/prettier-plugin-sort-imports' package trivago/prettier-plugin-sort-imports#204
johnvictorfs added a commit to jornadayu/yu-open-lib that referenced this issue Mar 27, 2023
Relevant issue for the package.json changes for the '@trivago/prettier-plugin-sort-imports' package trivago/prettier-plugin-sort-imports#204
johnvictorfs added a commit to jornadayu/yu-open-lib that referenced this issue Mar 31, 2023
Relevant issue for the package.json changes for the '@trivago/prettier-plugin-sort-imports' package trivago/prettier-plugin-sort-imports#204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants