Open
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.101.2
- OS Version: MacOS 15.5
Steps to Reproduce:
- Get project with Typescript
- Import an object - const or function from a file which does not exist, so the import is invalid
- In next line import the same object but now from a file where it exists, so the import is valid
- Run ">Typescript: Remove unused imports" command.
Example code ("./mocks.ts" does not exist):
src/modules/A/mocks.ts:
export const A = 'A';
src/test.ts:
import { A } from './mocks';
import { A } from 'src/modules/A/mocks';
console.log(A)
Current effect:
The command will leave the first invalid import, and remove the second valid import.
Expected:
The valid import (second) should stay, and the invalid (first) should be removed.
Comments:
It looks like the command does not take into consideration if the import is valid or not.
Use cases:
- Resolving merge conflicts. After both merge changes are accepted the result mixes valid and invalid imports. "Typescript: Remove unused imports" should then remove import duplicates, but leave the valid ones and remove invalid ones, not the other way.
- Fixing imports by hand. After adding a new valid import by hand at the end of imports "Typescript: Remove unused imports" will remove it and leave the invalid one
Metadata
Metadata
Assignees
Labels
No labels