typescript-go
typescript-go copied to clipboard
Inherited `baseUrl` is not respected
// @filename: src/tsconfig.json
{
"extends": "../configs/tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"module": "nodenext",
"outDir": "../dist",
"strict": true,
},
"include": ["**/*"],
}
// @filename: configs/tsconfig.base.json
{
"compilerOptions": {
"baseUrl": "../src",
"paths": {
"@/*": ["*"]
}
}
}
// @filename: a.ts
export const foo = 123;
// @filename: b.ts
import { foo } from "@/a.js";
foo + foo;
b.ts:1:21 - error TS2307: Cannot find module '@/a.js' or its corresponding type declarations.
1 import { foo } from "@/a.js";
~~~~~~~~
Found 1 error in b.ts:1
Files: 84
Lines: 41514
Identifiers: 45336
Symbols: 40210
Types: 22379
Instantiations: 10412
Memory used: 43739K
Memory allocs: 326267
Parse time: 0.029s
Bind time: 0.007s
Check time: 0.110s
Emit time: 0.007s
Total time: 0.152s
baseUrl isn't supported: #474
I guess @andrewbranch clarified that baseUrl is meant to be deprecated in 6.0 over at #474. I ran into this when trying to compile https://github.com/getsentry/sentry, which has a directory structure like the following:
.
├── configs/
│ └── tsconfig.base.json
├── tsconfig.json
└── src/
├── fileA.tsx
└── fileB.tsx
tsconfig.base.json specifies a baseUrl back at the top level
{
// ...
"baseUrl": "..",
"paths": { /*...*/ },
// ...
}
But then I'm guessing all the specifiers are resolved relative to the base config file and so this just breaks.
Is the intended workaround the following?
- "baseUrl": "../",
"paths": {
- "sentry/*": ["static/app/*"],
- "sentry-fixture/*": ["tests/js/fixtures/*"],
- "sentry-test/*": ["tests/js/sentry-test/*"],
- "getsentry-test/*": ["tests/js/getsentry-test/*"],
- "sentry-images/*": ["static/images/*"],
- "sentry-locale/*": ["src/sentry/locale/*"],
- "sentry-logos/*": ["src/sentry/static/sentry/images/logos/*"],
- "sentry-fonts/*": ["static/fonts/*"],
- "getsentry/*": ["static/gsApp/*"],
- "getsentry-images/*": ["static/images/*"],
- "admin/*": ["static/gsAdmin/*"]
+ "sentry/*": ["../static/app/*"],
+ "sentry-fixture/*": ["../tests/js/fixtures/*"],
+ "sentry-test/*": ["../tests/js/sentry-test/*"],
+ "getsentry-test/*": ["../tests/js/getsentry-test/*"],
+ "sentry-images/*": ["../static/images/*"],
+ "sentry-locale/*": ["../src/sentry/locale/*"],
+ "sentry-logos/*": ["../src/sentry/static/sentry/images/logos/*"],
+ "sentry-fonts/*": ["../static/fonts/*"],
+ "getsentry/*": ["../static/gsApp/*"],
+ "getsentry-images/*": ["../static/images/*"],
+ "admin/*": ["../static/gsAdmin/*"]
},
See also https://github.com/shadcn-ui/ui/pull/7342