-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Manual import path mapping for TypeScript projects #36105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@alshdavid To workaround this, could you have two tsconfigs:
That would accomplish the same thing as a setting |
I suppose that is a solution. I feel the inclusion of arbitrary (and ignored) compiler configuration to help IDEs interpret what will be resolved differently after compile time only adds confusion. Is it possible to instruct vscode to look at a specific tsconfig? perhaps that way I could configure a |
VS Code currently always looks for files called A vscode setting would also be a separate configuration so I'm not convinced it would any better (and it would be vscode specific) |
+1 The key point is IDE intelligence. |
I'm also running into this issue. I'm finding it tricky to visualize how to model everything |
When using TypeScript with a monorepo containing multiple packages, there is no way to have effective source path mapping for intellisense purposes.
It would be very helpful to have the capacity to manually add path resolution configuration for VSCode in the workspace
settings.json
rather than relying on VSCode figuring out paths from the available configuration.Problem Case:
Imagine I have two libraries
a
andb
:If inside
b
I importa
using:During compilation, the above path would be resolved by webpack (or yarn workspaces) to
../a
, where themain
key in thepackage.json
will instruct node to finda/dist/index.js
.During development, I want to map
@org/a
to../a/src/index.ts
so intellisense will send me to the source folder rather than the build folder.TypeScript has a paths option in the
tsconfig.json
which I can use insideb
by mapping:This works well in my IDE however, when using tsconfig paths, the typescript compiler for
b
emitsa
's types in it's build folder when compiled - like so:For comparison, without including the
tsconfig.json
paths
configuration insideb
, this is whatb
's build folder looks like:Using
tsconfig.sjon
paths
results in the inclusion of files I don't want in my project and breaks thetypes
key inb
'spackage.json
Module mapping for development really isn't TypeScript's job, I feel it's important that we include the ability for VSCode to resolve module pathing via a manual configuration.
Suggestion:
Perhaps something like:
.vscode/settings.json
The text was updated successfully, but these errors were encountered: