daidodo / daidodo/format-imports
Improve importType support (`import type` vs`import { type }`)
- Dominant language
- TypeScript
- Stars
- 51
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
VSCode auto-import does not reliably put import types in a separate import tag,
ie. depending on what's pre-existing, it may do different style :
```ts
import type { A } from '.foo1'
import { type B } from '.foo2'
import { type C, bar } from '.foo3'
import { type D, type E, baz, qux } from '.foo4'
```
It would be great if `format-imports` could fix it by formatting them like this:
```ts
import type { A } from '.foo1'
import type { B } from '.foo2'
import type { C } from '.foo3'
import { bar } from '.foo3'
import type { D, E } from '.foo4'
import { baz, qux } from '.foo4'
```
For now, we have `importType` that will properly groups `import type`, but won't do anything when `type` is inside the bracket.
Thanks!
Contributor guide
Research direction
Start by reading the existing importType handling in format-imports and trace how imports with type-only specifiers are classified. Done means converting `import { type X }` and mixed imports into separate type and value imports with the requested grouping, while preserving module paths and imported names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100