Skip to content

chore: use #* instead of #/* in root package subpath imports#2

Merged
amanx5 merged 1 commit into
dev-002from
vsc-auto-imports
Jun 9, 2026
Merged

chore: use #* instead of #/* in root package subpath imports#2
amanx5 merged 1 commit into
dev-002from
vsc-auto-imports

Conversation

@amanx5

@amanx5 amanx5 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Enable VS Code auto-import suggestions for non-relative paths without configuring tsconfig baseUrl or paths.

Issue

With typescript.preferences.importModuleSpecifier set to non-relative, VS Code only suggests subpath imports when package.json uses #* rather than #/*.

Case 1 - When #/* alias is set: VSC/TS is NOT ABLE to suggest auto import for "REPO_DIR" symbol.
auto import using #slash

Case 2 - When #* alias is set: VSC/TS is ABLE to suggest auto import for "REPO_DIR" symbol.
auto import using #

Why not just set baseUrl or paths?

TypeScript 6 deprecates baseUrl, leaving paths as the main alternative for the "non-relative" auto import feature to work, but setting up paths is extra overhead. The package.json already uses Node subpath imports and TS v6 has built-in support for Node subpath imports.

Trade-off:

#/* provides better path completion when typing imports manually. #* fails in manual import suggestions.

Case 1 - When #/* alias is set: VSC/TS correctly resolves and suggests all the files present in the repository root when path #/ is typed in an import declaration.
manual import using #slash

Case 2 - When #* alias is set: VSC/TS either ignores or is not able to resolve/suggest the files present in the repository root when path # is typed in an import declaration. This can be due to VSC prioritizing region folding suggestions when "#" is typed.
manual import using #

Enable VS Code auto-import suggestions for non-relative paths without
configuring tsconfig `baseUrl` or `paths`.

With `typescript.preferences.importModuleSpecifier` set to `non-relative`, VS Code
only suggests subpath imports when package.json uses `#*` rather than `#/*`.

TypeScript 6 deprecates `baseUrl`, leaving `paths` as the main alternative,
which requires extra tsconfig setup.

TS v6 has built-in support for Node subpath imports.

Trade-off: `#/*` provides better path completion when typing imports manually.
`#*` fails in manual import suggestions.
@amanx5 amanx5 merged commit af9272e into dev-002 Jun 9, 2026
1 check passed
@amanx5 amanx5 deleted the vsc-auto-imports branch June 9, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant