Repository navigation
Deprecate, remove support for baseUrl #62207
Description
Today, baseUrl performs two functions:
- it acts as a prefix for all entries in
paths - it acts as a potential resolution point for all bare paths
But almost nobody realizes that last part. It means if you have the following:
{
"compilerOptions": {
// ...
"baseUrl": "./src",
"paths": {
"@app/*": ["app/*"],
"@lib/*": ["lib/*"]
}
}
}An import like
import * as blah from "blah.js";might resolve to ./src/blah.js.
Usually, developers who wrote this only intended to re-map any modules that started with @app/ and @lib/. Unfortunately people specify a baseUrl because it was previously required to make paths work or as a prefix.
In TypeScript 7.0, we are not reimplementing baseUrl.
Instead, paths will need to manually specify a custom prefix.
{
"compilerOptions": {
// ...
- "baseUrl": "./src",
"paths": {
- "@app/*": ["app/*"],
- "@lib/*": ["lib/*"]
+ "@app/*": ["./src/app/*"],
+ "@lib/*": ["./src/lib/*"]
}
}
}In the event that you want to maintain the same behavior as before, you can add an additional path mapping for the baseUrl itself:
{
"compilerOptions": {
// ...
"paths": {
// A new catch-all that replaces the baseUrl:
"*": ["./src/*"],
// Every other path now has an explicit common prefix:
"@app/*": ["./src/app/*"],
"@lib/*": ["./src/lib/*"],
}
}
}In TypeScript 6.0, we will be deprecating this behavior. Using baseUrl will lead to an error which can only be resolved by applying one of the above fixes, or using --ignoreDeprecations.
Activity
oliviertassinari commentedon Oct 11, 2025
I have tried this in mui/base-ui#2969, but it didn't work.
I could only find two things that work with TypeScript 5.9.3 (latest stable):
Both are weird. Per what https://www.typescriptlang.org/tsconfig/#extends describes, the
extendsshould duplicate the paths values, and resolve the path relative to the extends file.But it's not what happens. It looks like a bug in TypeScript
extendsbehavior.DanielRosenwasser commentedon Oct 12, 2025
Olivier Tassinari (@oliviertassinari) do you mean a bug in TS 6 (our usual nightlies?) or
@typescript/native-previewor both?oliviertassinari commentedon Oct 12, 2025
I was expecting to be able to remove
baseUrlontypescript@5.9.3.andrewbranch commentedon Oct 13, 2025
extendsdoes not mergepathsvalues. They are always fully overridden.oliviertassinari commentedon Oct 13, 2025
Andrew Branch (@andrewbranch) Yeah, this part seems all good. I didn't observe a problem with the merge behavior of
extendswithpaths.The issue is with the paths resolution.
andrewbranch commentedon Oct 13, 2025
Sorry, this stuff is super confusing to talk about. The expected behavior is that in whatever file you actually define
paths, the relative paths are always resolved to that file. In the past, it was possible for a base config to definepaths, and many extending configs to definebaseUrl, which would cause the singlepathsdefinition to effectively be reinterpreted against a differentbaseUrlfor every project. That was never really an intentionally designed feature, just a consequence of the natural interaction between two features. We don’t expect many people were doing that on purpose, but if you were, you will end up definingpathsin more config locations than before. https://github.com/andrewbranch/ts5to6 should be able to handle that migration automatically.fix(api): deprecated baseUrl usage
15 remaining items
Jasper-Nelligan commentedon Apr 10, 2026
When I try the catch-all solution by adding
"*": ["./*"]to mypaths, VSCode will start auto-suggesting imports fromnode_moduleswhich is incorrect. Is anyone else facing this issue?Remove baseUrl from all tsconfig files ahead of TS 6.0 deprecation
fix: remove deprecated baseUrl
ruizmarc commentedon Apr 21, 2026
Yeah, same problem here, all autoimports start with node_modules/ instead of the name of the library
li-zck commentedon Apr 22, 2026
Yes. Does anyone have the workaround?
RyanCavanaugh commentedon Apr 22, 2026
Please post a new issue with a repro so that we can investigate.
Changed tsconfig.json to fix deprecation warning for `baseUrl`, see m…
lppedd commentedon May 17, 2026
I have not seen anyone mention this error with 5.9.3:
Is this supposed to be resolved in 6.x? My current
pathsare like the following:Edit: if this is considered a supported use case for TS, this might be caused by Nx.
Merge/develop into admin-ui/main (#1828)
chores: 解决ts警告 (#566)
fix: remove `baseUrl` from TypeScript configuration
fix(backend): Remove deprecated baseUrl option from tsconfig
fix(api): deprecated baseUrl usage
test(deps): keep the typescript hold while either blocker stands
chore(deps): hold typescript 7 and openai 3 back with a guarded ignore (