Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tsconfig.json files with extends property #29

Open
cmolina opened this issue Mar 24, 2022 · 5 comments
Open

Add support for tsconfig.json files with extends property #29

cmolina opened this issue Mar 24, 2022 · 5 comments

Comments

@cmolina
Copy link

cmolina commented Mar 24, 2022

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?

@tal-rofe
Copy link

tal-rofe commented Apr 5, 2022

@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.

@jjcfatras
Copy link

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.

@gustavopch
Copy link
Owner

@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.

@cmolina
Copy link
Author

cmolina commented Aug 17, 2022

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.

@gustavopch
Copy link
Owner

Agreed, I'm just using plain tsc these days myself. One can also use --incremental flag if it's slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants