Reuse existing import if already defined in the file

Open
#5 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
babel, typescript
Domain
tooling

Research direction

Start by locating the TypeScript import-move codemod logic that rewrites source and destination imports. Reproduce the example using the existing project test or codemod entry point, then verify that the moved specifier is merged into the existing destination import rather than emitted as a duplicate.

Written by the indexing model from the issue text.

Description

enhancement

If we move from let say packlets/utils to @acme/utils and in the file, there is already a @acme/utils imports we should add imports to it and do not create a new one.

So from:

import { fn1 } from 'packlets/utils'
import { fn2 } from '@acme/utils'

To:

import { fn2, fn1 } from '@acme/utils'

Currently it will generate following:

import { fn1 } from '@acme/utils'
import { fn2 } from '@acme/utils'
Dominant language
TypeScript
Stars
13
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.