You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.
|- index.tsx
|- components
| |- index.ts
| |- A
| |- index.tsx
| |- B
| |- index.tsx
Where baseUrl: "." and index.ts files are written in way to export modules up the tree:
-- components/index.ts --
export * from './A'
export * from './B'
When editing any files under components or its subfolders, if you try to import component Ausing tab to autocomplete, intellisense will automatically add an import from components/A instead of from just components.
Auto importing with quick fix Ctrl+. works as expected. The gif below demonstrates both tabbing and using quick fix.
See, quick fix gets the sorting right, and in case the first choice is already imported it even hides the other options which is fine.
In VSCode, that happens regardless of selecting Import Module Specifier as shortest or non-relative. (Though shortest sometimes results in relative paths).
I haven't seen the problem happen in files not under components. It works as expected.
🔎 Search Terms
Autocomplete, auto import, intellisense, import module specifier
Bug Report
In a project structured like this:
Where
baseUrl: "."
andindex.ts
files are written in way to export modules up the tree:When editing any files under
components
or its subfolders, if you try to import componentA
using tab to autocomplete, intellisense will automatically add an import fromcomponents/A
instead of from justcomponents
.Auto importing with quick fix
Ctrl+.
works as expected. The gif below demonstrates both tabbing and using quick fix.See, quick fix gets the sorting right, and in case the first choice is already imported it even hides the other options which is fine.
In VSCode, that happens regardless of selecting Import Module Specifier as
shortest
ornon-relative
. (Though shortest sometimes results in relative paths).I haven't seen the problem happen in files not under
components
. It works as expected.🔎 Search Terms
Autocomplete, auto import, intellisense, import module specifier
🕗 Version & Regression Information
TS 4.2.2 and up
⏯ Playground Link
Fully reproducible here: https://codesandbox.io/s/hidden-lake-9jfk3?file=/src/components/A/index.tsx
🙂 Expected behavior
Autocomplete on tab should import module with the shortest possible path, just like quick fix, especially if selected
non-relative
as the specifier.The text was updated successfully, but these errors were encountered: