chore: use #* instead of #/* in root package subpath imports#2
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable VS Code auto-import suggestions for non-relative paths without configuring tsconfig
baseUrlorpaths.Issue
With
typescript.preferences.importModuleSpecifierset tonon-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.Case 2 - When

#*alias is set: VSC/TS is ABLE to suggest auto import for "REPO_DIR" symbol.Why not just set baseUrl or paths?
TypeScript 6 deprecates
baseUrl, leavingpathsas 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.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.