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
It would be very helpful if typescript followed the conventions of pretty much every other JS-stack tool and allowed the configuration to be done as a javascript file so they can more easily be manipulated.
For example all these tools (and many more) already accept configuration files to be javascript:
My suggestion is for typescript tsconfig resolver to look for a tsconfig.js file if available, if so require() it and use the exported values as configuration. If that file is not available then follow the current resolver rules for tsconfig.json.
Right now it is impossible to merge arrays when using the "extends" option of tsconfig.json. If the configuration were javascript files this would be feasible:
Duplicate of #30400. Used search terms: tsconfig.js
Reacted by Karam ELHABOUTI, Russell Dempsey, ipid, Andrey Kuzmin, Gheorghe Gherciu, Ocean, Vesa Nikkilä, Alexander Dmitrievich, tpu-ableton, b-derksen and 17 more
#30400 should have been marked a duplicate of this one. This issue does a much better job of explaining why we need this feature. one tsconfig.json simply doesn't cut it for more complicated projects.
Reacted by Aaron Cordova, Dan Cavanagh, Anthony Master, Adrien Foulon, Bruno Fantauzzi, Alexandr Nilov and TJ Rothwell
Why was this issue closed? This is a fantastic suggestion. I'm looking to dynamically set compilerOptions.paths and with json, that's just impossible.
Reacted by Sumit Chahal, spc16670, Valentin Gurkov, Adrien Foulon, Anton, Jordan Paisley and Tomás Amaro
Reacted by Istvan Tutto, Rocío, Alex Hunt, CEbbinghaus, Anthony Madhvani, Michael Ikechi, C. L. Jones, Lukas Frischknecht, Fabio Cencetti, Mario Hamann and 29 more
Up. Having all the setup json as js files is the future already happening.
Reacted by faissalbyld, Santiago, michael, David Meents, محمد الصوالحي, Dan Donahoe, Damien Dall'agnola, Oleh Vanin, Alexander Chashchin, Son Sumin and 4 more
Reacted by St John Peaster, placidlyUnsalted, Dominic Beinenz, Santiago, David Meents, Anatoly Babin, Pavel Myagkov, Son Sumin, Anthony Master and Valentin Gurkov
Aaron Cordova (@qodesmith) actually it's not impossible, it's very easy 👍
@SrBrahma maybe generating the JSON files is more futuristic 🙏
Just read the file using fs.readFile or fs.readFileSync with option { encoding: "utf8" }
JSON.parse() the string you get
update your JSON however you like dynamically
JSON.stringify() the final JSON before...
write the file back where it belongs using fs.writeFile or fs.writeFileSync
I was looking if .js is allowed but it's easy to just generate your config files (all of them) then add a CLI or whatever and configure or set some default templates, etc.
Reacted by Bruno Fantauzzi, misbeliever, Ten Bitcomb, Rafael Sangalli, roshal, zanminkian, Allan Pinheiro de Lima, silverwind and Tomás Amaro
Fabio Gartenmann (@faeb187) That would not work if your config includes non encodable content, like functions, which would be the use case for a .js file
Adrien Foulon (@Tofandel) What Fabio Gartenmann (@faeb187) is suggesting is manipulating JSON data by reading, updating, and re-writing the data back to disk. Since the source of truth would be a JSON file, there wouldn't be any non-encodable content. It's essentially the same solution I came up with a while ago, but it's still a hack.
Activity
[-]Javascript config file (tsconfig.js)[/-][+]Javascript tsconfig file (tsconfig.js)[/+]MartinJohns commentedon Jul 6, 2020
Duplicate of #30400. Used search terms:
tsconfig.jsStJohn3D commentedon Feb 11, 2022
#30400 should have been marked a duplicate of this one. This issue does a much better job of explaining why we need this feature. one tsconfig.json simply doesn't cut it for more complicated projects.
qodesmith commentedon Feb 12, 2022
Why was this issue closed? This is a fantastic suggestion. I'm looking to dynamically set
compilerOptions.pathsand with json, that's just impossible.ftzi commentedon May 9, 2022
Up. Having all the setup json as js files is the future already happening.
faeb187 commentedon Mar 24, 2023
Aaron Cordova (@qodesmith) actually it's not impossible, it's very easy 👍
@SrBrahma maybe generating the JSON files is more futuristic 🙏
fs.readFileorfs.readFileSyncwith option{ encoding: "utf8" }JSON.parse()the string you getJSON.stringify()the final JSON before...fs.writeFileorfs.writeFileSyncI was looking if
.jsis allowed but it's easy to just generate your config files (all of them) then add a CLI or whatever and configure or set some default templates, etc.Tofandel commentedon Jun 20, 2023
Fabio Gartenmann (@faeb187) That would not work if your config includes non encodable content, like functions, which would be the use case for a
.jsfileqodesmith commentedon Jun 24, 2023
Adrien Foulon (@Tofandel) What Fabio Gartenmann (@faeb187) is suggesting is manipulating JSON data by reading, updating, and re-writing the data back to disk. Since the source of truth would be a JSON file, there wouldn't be any non-encodable content. It's essentially the same solution I came up with a while ago, but it's still a hack.