microsoft / microsoft/TypeScript

Paste with imports duplicates imports for namespace imports

Open
#60,419 1 comment 0 reactions 1 assignee View on GitHub

@navya9singh is already working on this.

Since Nov 12, 2024.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms
  • paste with imports
  • paste update imports
🕗 Version & Regression Information

5.7.0-dev.20241030

⏯ Playground Link

No response

💻 Code

consts.ts

export const a = 123;

console.log(a);

index.ts

import * as consts from "./consts";

console.log(consts.a);
  1. In consts.ts, copy console.log(a);
  2. Paste into index.ts
🙁 Actual behavior

Imports get duplicated:

import * as consts from "./consts";
import { a } from "./consts";

console.log(consts.a);
console.log(a);
🙂 Expected behavior

It should rewrite the code to use the existing import:

import * as consts from "./consts";

console.log(consts.a);
console.log(consts.a);
Additional information about the issue

No response

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.