Closed haoqunjiang closed 3 years ago
Thanks for pointing this out. For now your best alternative is to install ts and use (doesn't work, see below)parseNative
which should support this ootb.
parse
2 things are neededfoo/bar/input.ts
file is included in the tsconfigSolutions tend to have large codebases making the process less than fast. Maybe it's possible to parallelize with async
How to handle cases where multiple references match
Is it legal to have a references b
+ b references c
or a references b
+ b extends a
?
That could get "interesting"
more resources: https://www.staging-typescript.org/docs/handbook/project-references.html#what-is-a-project-reference typescripts own "solution": https://github.com/microsoft/TypeScript/blob/main/src/tsconfig.json
Whats interesting here is that they use directories as paths in the references
section. This case is already supported by tsconfck, as the actual closest tsconfig.json is correctly being picked up.
So as a workaround we could check for existing references that point to files not named tsconfig.json and throw an Error infoming the user that this tsconfig cannot be safely parsed without using parseNative
i'll try to setup a branch with a test fixture.
here it is: https://github.com/dominikg/tsconfck/tree/feat/support-solution-style
unfortunately the current "native" implementation also only returns the solution tsconfig, so finding the correct one would need to be done for both parse and parseNative.
added an initial implementation in https://github.com/dominikg/tsconfck/tree/feat/support-solution-style
It includes a pretty crude include pattern to regex approach to find the matching solution where i am not sure if thats exactly how it works inside of typescript but it's a start. https://github.com/dominikg/tsconfck/blob/db98a0f550e882b8ac1382a03d7d290bdc8d9015/src/util.ts#L118
Would love to completely drop using regex there and instead do a single pass character scan, but i need to think about how to properly implement greed for **/
Describe the feature
TypeScript 3.9 adds this feature called “Solution Style”
tsconfig.json
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#support-for-solution-style-tsconfigjson-filesIn this case, the actual
tsconfig
may reside in files named not exactly astsconfig.json
. The foundtsconfig.json
is only a "solution" file that references other configuration files.A Usecase
Some large full-stack repositories may use it. Those who put
.spec.ts
files alongside the source files may need it too.Alternatives
Not sure whether this feature should be implemented in this package, or in a separate package.
If we're to support this feature, all top-level options in
tsconfig.json
need to be processed, includingfiles
,overwrites
,include
,exclude
andreferences
.Additional context
N/A