Closed
Description
Bug Report
When a user has source.organizeImports
enabled on save/blur, the imports are mistakenly removed if the file contains errors. It also happens file contains an unclosed block comment /*
(for example, when the file got saved in the middle of writing a comment).
🔎 Search Terms
- Remove unused imports
- source.organizeImports
🕗 Version & Regression Information
typescript@4.1.2
VSCode:
Version: 1.53.2
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:45:54.515Z (2 wks ago)
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 19.6.0
- This is a crash: No
- This changed between versions ______ and _______: I do not recall this ever working
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because do not have an environment setup.
⏯ Playground Link
- I do not know how to trigger
source.organizeImports
in a playground.
💻 Code
An example of a broken file. This example contains JSX, hover, the point here if the file IS broken, then we should not remove imports.
File: test.ts
(NOT test.tsx
)
import { uniq } from "lodash";
export default function useAssetTypeFilterOptions() {
return (
<input
name="aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
value={uniq(["a", "b", "c"]).join(" + ")}
/>
);
}
🙁 Actual behavior
- The imports are erroneously removed
🙂 Expected behavior
- The imports should not be removed if the source file contains errors.