[Improvement] Let typescript load the config file, instead of tsconfig package
See original GitHub issueHi there,
I’ve just switched some of my playground projects to use ts-jest instead of my own typescript preprocessor. While I really appreciate to have less code to maintain, I’ve recognized that ts-jest uses a quite complex way to load the configuration file built upon the tsconfig package.
And I’m wondering why. Typescript itself offers a readConfigFile
function:
import * as tsc from "typescript";
const result = tsc.readConfigFile("tsconfig.json", tsc.sys.readFile);
In this example, result.config
would contain the config in case everything worked fine, or some diagnostics in result.error
in case it failed to read it.
It would be especially useful in terms of the extends
property, which is handled automatically (and its handling in the TS source looks by far more complicated than the one from ts-jest).
Any thoughts?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TSConfig Reference - Docs on every TSConfig option
The configuration from the base file are loaded first, then overridden by ... engine to improve performance, and makes a set of errors...
Read more >Documentation - What is a tsconfig.json - TypeScript
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file...
Read more >Documentation - tsc CLI Options - TypeScript
Flag Type Default
‑‑allowJs boolean false
‑‑allowUmdGlobalAccess boolean false
‑‑allowUnreachableCode boolean
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Docs on every TSConfig option - TypeScript
This config file will include all packages under ./typings and ./vendor/types , and no packages from ./node_modules/@types . All paths are relative to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hm… yes, things seem to be a bit more complicated, though I’m a bit surprised - I recently used the same for a PR in another project, and things worked fine. I’ll dig a little bit deeper into this…
€dit: Ok, after taking a closer look, I can confirm that
tsc.readConfigFile
does not follow theextends
directive. It’s a bit surprising to me, since I’ve seen that working without a problem in several projects, not only mine - otherwise, I wouldn’t have suggest to go this way.However, after checking out how TypeScript’s cli is picking up the config, it seems to involve the usage of
tsc.parseJsonConfigFileContent
as well. Due to the source, this one recursively follows theextends
entry, picking up the referenced files and merging the options as intended. I’ll see if I can get that working.Strange. In my attempts I simply got an object with an “extends” key. That’d be awesome