Open ThiloAschebrock opened 2 years ago
The same issue also happens if you are using the new Typescript instantiation expressions, cf. https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#instantiation-expressions.
This is because this project locks the babel versions used. It's updated in https://github.com/trivago/prettier-plugin-sort-imports/pull/161. Or, you can use https://github.com/ianvs/prettier-plugin-sort-imports which does not lock the babel version.
I apologize if this has been discussed previously here, but instead of pinning dependencies on exact versions, wouldn't it be better to allow any version of dependencies that are on the same major?
So instead of
"@babel/parser": "7.18.9",
rather do
"@babel/parser": "^7.18.9",
I apologize if this has been discussed previously here, but instead of pinning dependencies on exact versions, wouldn't it be better to allow any version of dependencies that are on the same major?
So instead of
"@babel/parser": "7.18.9",
rather do
"@babel/parser": "^7.18.9",
Yes, and this what the fork is doing: https://github.com/IanVS/prettier-plugin-sort-imports/blob/main/package.json#L46
Your Environment
Describe the bug
prettier-plugin-sort-imports results in SyntaxError when combined with
typescript
parser and newer syntax for Typescript types, cf https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#extends-constraints-on-infer-type-variables.To Reproduce
test.ts
:result in the following error when running prettier with
prettier-plugin-sort-imports
enabled:Note that this error is not present when manually selecting
babel-ts
as the prettier parser or running prettier with--no-plugin-search
to disable the plugin.Expected behavior
No error for this syntax when using prettier with the
typescript
parser andprettier-plugin-sort-imports
.