Microsoft/TypeScript
GitHub ã§èŠãImport auto-import doesn't take into account the current import statement
Open
#52,788 opened on 2023幎2æ15æ¥
Experience EnhancementHelp WantedSuggestion
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
- import
- auto-import
ð» Code
Use Visual Studio for the following:
- In
file1.ts, writeexport zero = 0; - In
file2.ts, writeimport zeand notice the completion entry forzero.
ð Actual behavior
If the completion entry for zero is selected, the contents in file2.ts will be replaced by:
import { zero } from "./file1.ts";
import z
After discussing the bug with @andrewbranch, he pointed out how this is the correct behavior because the entry that VS is showing corresponds to an auto-import.
ð Expected behavior
The auto-import completion entry shouldn't show up if the current line corresponds to an import statement itself (in case the editor doesn't have preferences.includeCompletionsForImportStatements and preferences.includeCompletionsWithInsertText set).