Skip to content

BUG: TS: Functionality Refactor: move to constant to existing file: if from that existing file already present import to current file, refactor will not reuse that import but instead adds new one #59027

Open
@psnet

Description

@psnet

Does this issue occur when all extensions are disabled?: Yes

Version: 1.90.0 (user setup)
Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573

Steps to Reproduce:

Functionality Refactor: move to constant to existing file: if from that existing file already present import to current file, refactor will not reuse that import but instead adds new one

  1. Two files:
// File `a.ts`
import {b} from b.ts;

const test = 2;
// File `b.ts`
export const b = 2;
  1. Now use Refactor constant test from file a.ts to existing file b.ts.

ER

file a.ts should be:

// File `a.ts`
import {b, test} from b.ts;

file b.ts should be:

// File `b.ts`
export const b = 2;
export const test = 2;

AR

file a.ts is:

// File `a.ts`
import {b} from b.ts;
import {test} from b.ts;        // problem here: 2 imports from same file

file b.ts is:

// File `b.ts`
export const b = 2;
export const test = 2;

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions