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

Type imports are broken #29

Open
SebTVisage opened this issue Apr 11, 2024 · 2 comments
Open

Type imports are broken #29

SebTVisage opened this issue Apr 11, 2024 · 2 comments

Comments

@SebTVisage
Copy link

Hi.

Problem:
If I run prettier with the plugin on the file containing this import:

import {
  type DELAYED_TASK_NAME, // This is badly interpreted by the plugin
  DelayedTasksService,
  PendingTask,
} from '../domain/delayed-tasks-service.interface';

It gets transformed into:

import {
  DELAYED_TASK_NAME,
  DelayedTasksService,
  PendingTask,
  type, // keyword `type` is handled like an imported member
} from '../domain/delayed-tasks-service.interface';

Which is breaking TS.

Context:
I'm using this plugin v0.0.7 with import-sort-style-module v6.0.0. Here's my config file

{
  ".js, .jsx, .es6, .es, .mjs, .ts, .tsx": {
    "parser": "typescript",
    "style": "module"
  }
}

Workaround
I can fix it by manually changing the code above to:

import {
  DelayedTasksService,
  PendingTask,
} from '../domain/delayed-tasks-service.interface';
import type { DELAYED_TASK_NAME } from '../domain/delayed-tasks-service.interface';

But that's annoying. And using the original syntax can create errors if we do not notice prettier's changes

@SebTVisage
Copy link
Author

This may be an issue with the upstream sort-import. It seems completely dead though, compared to issues being replied to in this repository. Is the project unmaintained?

@HaveSpacesuit
Copy link

I don't know if this project is maintained anymore; I found a workaround to the issue by disabling TypeScript > Preferences: Prefer Type Only Auto Imports in VS Code settings; it won't add type for auto-imports, but when Prettier formats the imports, it does add a type-only import on its own line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants