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
I've read the docs and open issues like #10866 and #16088. I understand that the baseUrl and paths options are designed to be used by bundlers, and do not affect code emitted by tsc.
I use esbuild and have gotten it to successfully transpile my code. However, esbuild (and many other bundlers) don't perform type checking and explicitly recommend using tsc --noEmit separately to do so.
But since tsc doesn't resolve relative to baseUrl or paths, type checking fails if I use paths and/or baseUrl, since those modules cannot be resolved.
π Motivating Example
Users of esbuild, swc, and shouldn't have to choose between the following two options:
Without type-checking
import { context } from "context"
With type-checking
import { context } from "../../../../context"
They should have the best of both worlds.
π» Use Cases
What do you want to use this for?
To write prettier code while keeping all the benefits of type-checking and esbuild.
What shortcomings exist with current approaches?
Other module bundlers exist, but they're slow and lack features. Besides, this solution would mean we'd stop having to rely on module bundlers for type-checking.
module-alias paths are global, so it's hard to use in monorepo setups. Also only works in node.
tsc-alias only works with emitted code.
What workarounds are you using in the meantime?
Just writing ugly paths.
The text was updated successfully, but these errors were encountered:
Actually realized that what I'm asking for already works in a simple repo, but I'm working with a monorepo and it doesn't seem to be supported there.
I have a parent tsconfig.json and child tsconfig.jsons in each monorepo. In each tsconfig.json I've set baseUrl to be src. So relative paths are resolved correctly when I'm in a subdirectory containing a tsconfig.json, but not at the root (which is where I'm currently doing type-checking from). I'm learning that tsc only loads one tsconfig.json at a time, and not the one closest to the file as some other tools do.
I tried setting up projectReferences to get all the projects to get built together, but it looks like that doesn't work with noEmit as described here: #36917
π Search Terms
baseUrl, paths, alias, resolution, type-checking
β Viability Checklist
β Suggestion
I've read the docs and open issues like #10866 and #16088. I understand that the
baseUrl
andpaths
options are designed to be used by bundlers, and do not affect code emitted bytsc
.I use esbuild and have gotten it to successfully transpile my code. However, esbuild (and many other bundlers) don't perform type checking and explicitly recommend using
tsc --noEmit
separately to do so.But since
tsc
doesn't resolve relative tobaseUrl
orpaths
, type checking fails if I usepaths
and/orbaseUrl
, since those modules cannot be resolved.π Motivating Example
Users of esbuild, swc, and shouldn't have to choose between the following two options:
Without type-checking
With type-checking
They should have the best of both worlds.
π» Use Cases
What do you want to use this for?
To write prettier code while keeping all the benefits of type-checking and esbuild.
What shortcomings exist with current approaches?
module-alias
paths are global, so it's hard to use in monorepo setups. Also only works in node.tsc-alias
only works with emitted code.Just writing ugly paths.
The text was updated successfully, but these errors were encountered: