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
{{ message }}
Repository navigation
Add template variable ${configDir} (name to be determined) for file path substitutionย #57485
"extends", "compilerOptions", "paths", "outdir", "include", "exclude", "typeRoots", "tsconfig", "ability to make tsconfig paths relative to final config"
โ Viability Checklist
This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
Today when all the options that are file paths, are always relative to config they are specified in. But that also means that if you are extending tsconfig and you want eg say outDir to be same name but relative to your config, you have to re-specify it in the config. The proposal is to use template variable in base config which would mean that the resulting file paths are relative to final config directory. Name is to be determined.
A way to specify root config that can specify include and/or outDir and not needing to write than in each project.
Issues: #29172, #30163, #37227, #45050, #51213
Nice, I've just tried this out yesterday and it works like a charm.
Only issue I had was that somehow Intellisense in VS Code still showed me an error in the editor which wasn't actually a build error, like it doesn't understand the ${configDir} variable yet.
As I already said, it's only an error shown in the IDE (I did switch the workspace to use the project's typescript instead of the built-in one), running tsc works fine.
Maybe I'll just have to wait for VS Code to update the built-in TypeScript version once 5.5 is officially published (:
Nice, I've just tried this out yesterday and it works like a charm.
Only issue I had was that somehow Intellisense in VS Code still showed me an error in the editor which wasn't actually a build error, like it doesn't understand the ${configDir} variable yet.
As I already said, it's only an error shown in the IDE (I did switch the workspace to use the project's typescript instead of the built-in one), running tsc works fine.
Maybe I'll just have to wait for VS Code to update the built-in TypeScript version once 5.5 is officially published (:
You can go to a ts file then on the bottom right you can see a typescript button. If you press it you can select vs code ts version and set it to the projects version. If you downloaded the 5.5.0-beta from npm vs code could be set to use that type.
in the project's .vscode/settings.json (which I also committed), somehow it wasn't working anymore after restarting VS Code. I just manually switched the version again and now it's working as expected. ๐คท๐ปโโ๏ธ
Upon running next dev --turbopack, the tsconfig.json in the next app gets altered.
An include gets added .. which makes no sense. There are no .ts or .tsx files in packages/typescript-config
Upon running next dev --turbopack, the tsconfig.json in the next app gets altered. An include gets added .. which makes no sense. There are no .ts or .tsx files in packages/typescript-config
Activity
sheetalkamat commentedon Mar 29, 2024
Options that should check for
${configDir}Some of these options can be passed on commandline. Do we allow passing
${configDir}in themOptions that are of type string or object but should not check
${configDir}${configDir}is allowed is this ok to pass?${configDir}is allowed is this ok to pass?${configDir}Bessonov commentedon Apr 17, 2024
Thank you, Sheetal Nandi (@sheetalkamat), you are amazing!
karlhorky commentedon Apr 19, 2024
Sheetal Nandi (@sheetalkamat) Awesome job, thanks! ๐ looking forward to having this released in a TypeScript version for my shared tsconfigs ๐
Is it planned that this will be released in TypeScript 5.5? I didn't see it in the Iteration Plan:
D4N14L commentedon Apr 19, 2024
Sheetal Nandi (@sheetalkamat) thank you! This has been a feature I've wanted to see for some time now. Great to finally have it!
karlhorky commentedon Apr 29, 2024
Looks like will be a part of TS 5.5 (or at least is in the 5.5 Beta announcement):
simonhaenisch commentedon May 8, 2024
Nice, I've just tried this out yesterday and it works like a charm.
Only issue I had was that somehow Intellisense in VS Code still showed me an error in the editor which wasn't actually a build error, like it doesn't understand the
${configDir}variable yet.โ๏ธ this gave me the error so i tried moving the include into the composite project's
tsconfig.jsonand that worked:but then I tried using
${configDir}there as well and that didn't work either (thus the assumption that the var breaks it):As I already said, it's only an error shown in the IDE (I did switch the workspace to use the project's typescript instead of the built-in one), running
tscworks fine.Maybe I'll just have to wait for VS Code to update the built-in TypeScript version once 5.5 is officially published (:
ChurroC commentedon May 11, 2024
You can go to a ts file then on the bottom right you can see a typescript button. If you press it you can select vs code ts version and set it to the projects version. If you downloaded the 5.5.0-beta from npm vs code could be set to use that type.
simonhaenisch commentedon May 13, 2024
ChurroC (@ChurroC)
maybe you overlooked this?
Edit: anyway you're right. Even though I had done this before via command palette which created
{ "typescript.tsdk": "node_modules/typescript/lib" }in the project's
.vscode/settings.json(which I also committed), somehow it wasn't working anymore after restarting VS Code. I just manually switched the version again and now it's working as expected. ๐คท๐ปโโ๏ธjakearchibald commentedon Sep 10, 2024
This feature should be documented somewhere outside of https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files
mconnor commentedon Jan 16, 2025
I have a nextjs app set up in a monorepo and using this ${configDir} feature. The the tsconfig package has:
// some/path/tsconfig.json
Upon running next dev --turbopack, the tsconfig.json in the next app gets altered.
An include gets added .. which makes no sense. There are no .ts or .tsx files in packages/typescript-config
ArifRabbaniIn commentedon Aug 17, 2025
Same is happening for me as well