-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Existing import type prevents autocompletion of value import for TypeScript #44804
Copy link
Copy link
Closed
Closed
Copy link
Labels
Domain: LS: Auto-importDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
Domain: LS: Auto-importDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript
Type
Fields
Give feedbackNo fields configured for issues without a type.
Issue Type: Bug
Consider the following code:
Now type:
on a new line inside
a.tsand try to autocomplete the import ofBto use it as a constructor.Expected behaviour
VSCode changes the import of
Bfrom a type import to a value import.(It would be a syntax error to add the value import while keeping the type import, so the type import of
Bhas to be removed at the same time. In this particular example, I would expect the entireimport typeline to be removed and the import ofBadded to the same line asmakeB.)Observed behaviour:
VSCode offers an autocompletion dropdown, but the default choice does nothing. There is no choice that will result in a value import of B unless the existing type import is deleted.
Screencap:
Screen.Recording.2021-06-29.at.01.47.40.mov
This is a frustrating experience: If I "happen" to autocomplete something as a value in a given file before I complete it as a type the first time, then autocomplete works naturally and the code is fine. But if I autocomplete something as a type the first time, then VSCode is unable to autocomplete the value import. Even though I know the issue and can work around it every time, autocomplete feels subjectively unreliable.
This kind of situation can be common in a large codebase with
importsNotUsedAsValues. In particular, I'm working on a project where it is common to use a particular class (Algfromcubing/alg) as a the type of a variable in a given file, only to need the constructor later on.VS Code version: Code 1.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48, 2021-06-17T13:28:32.912Z)
OS version: Darwin x64 20.5.0
Restricted Mode: No
System Info
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
A/B Experiments