-
Notifications
You must be signed in to change notification settings - Fork 49
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
Type-check dependent files too #6
Comments
A way: https://github.com/dependents/node-dependency-tree |
@barroudjo I guess we need the opposite. Given the leaves of the tree, we should walk back through all parent nodes. Maybe something like:
|
That's actually what I'm saying, when I say walk back I mean find parents (ie files that use this changed file), and continue this process and return the path of all the files found through this process. Explanation, with a simple project file dependency tree (file A is the entry point):
If only D has changed you'll end up with files [A, B, C, D] that have to be type-checked. And from what I understood, when typescript is given a file, it checks it and all its dependencies, which makes sense. So with this process all files will end up being type checked, including E and F.
And in this case if D has changed only [A, B, C, D] will end up being type checked, not [E, F, G] |
@barroudjo Got it. I'm afraid you're right. In that case, is this tool even useful? 😟 |
Yes it is, because of that defect of typescript, where giving it a file in the cli makes it ignore the tsconfig.json. |
Convinced @gustavopch ? |
@barroudjo Yes, that makes sense. I've actually found out that my original "type-checking with |
Any progress on this? Or is it just an idea? |
@kibin Unfortunately not. I'm not currently using |
@barroudjo I think it might be possible to overcome the problem you describe. Given your scenario:
In the situation where
This might be possible with a little bit of trickery. I'm speculating a bit here; but since the compiler has a flag which allows you to compile modules without checking their dependencies (isolatedModules), we might be able to leverage this to achieve the intended outcome.
I'm making loads of assumptions here and I'm not saying its easy. But it might be possible. |
Just had this bite me -- changed a function signature but didn't update the implementation, but of course the implementation was not in the staged files so it passed. Running a tsc against the whole project would have caught it. Essentially we need what Jest has the Seems like the related code is here:
I was kind of hoping they used a 3rd party AST library, but it seems that they've baked in their own magic from my quick look at it. Either you could duplicate what they have stripping out irrelevant code like snapshots, coverage, mocks, or find an AST library that finds implementations of a given file/function(s). Quick surface level lib research: https://github.com/benjamn/ast-types |
Problem
Currently,
tsc-files
will receive a list of files as arguments and will only type-check them.Suppose you have the following two files:
Everything OK. But now imagine you apply some change to
types.ts
that would breakindex.ts
:And then you run
tsc-files
withlint-staged
, so thattsc-files
will only receive the files that were changed (index.ts
won't be type-checked because it wasn't changed). In that case,tsc-files
won't alert you thatindex.ts
is broken.Possible solution
To fix that behavior,
tsc-files
should be able to type-check not only the files given as arguments but also all files that recursively depend on those.The text was updated successfully, but these errors were encountered: