tsc-files
tsc-files copied to clipboard
Add support for tsconfig.json files with `extends` property
Hello, thanks for maintaining this project!
I am trying to run tsc-files
twice as part of a pre-commit hook, once for my app
files and then for my test
ones.
The app
works fine, since there is a tsconfig.json
at the root of my project.
However I haven't been able to run tsc-files
for my test
files, where I have another tsconfig file with this content:
// test/tsconfig.json
{
"extends": "../tsconfig.json"
}
when I run tsc-files -p -test/tsconfig.json
from <parent-directory>/my-repo/
I get:
error TS5083: Cannot read file '<parent-directory>/tsconfig.json'.
# notice how "my-repo/" is not in the path!
If I go into the test
directory and run tsc-files
, I get:
error TS6053: File '<parent-directory>/my-repo/<path-to-file>' not found.
# and <path-to-file> doesn't start with "test/"
Am I missing something?
If this is not supported yet, are you interested in receiving PRs for adding this functionality?
@cmolina
Actually I can see the index.js
file would append "extends" as well to the temporary tsconfig file.
As far as I know he is interested in PRs.
Has there been any updates on this? I'm trying to add this to a monorepo but I'm having issues where path aliases defined in a child package's tsconfig.json file are being ignored.
@jjcfatras No updates on this. Unfortunately, I'm not finding any time to dedicate to this project. But the whole thing is about 50 lines of code, so I recommend copying the code and adjusting to your needs.
I am going to go a little off-topic here, but maybe I can save some time to the future reader.
I was very eager to add support for extends
; but then I realized that this project is not doing what I was expecting. I was hoping to determine if my current changes would break my app. But it is not enough to compile the edited files; you still need to run tsc
over all the other files that depends on the edited files. You can read more about it in #6.
I am not sure if TypeScript has an API for this (i.e. get a list of all the files that are affected by a single update). Until then, if your purpose here is to make sure your change didn't break your app/library, you will probably need to run tsc
anyway.
Having said that, if you are okay with this limitation and you still need support for extends
, it should be pretty straightforward to add.
Agreed, I'm just using plain tsc
these days myself. One can also use --incremental
flag if it's slow.