ts-jest: type changes not updated during watch mode
Issue
When you make changes to the types, e.g. renaming a type, the changes cause the test to fail, even if the change actually works fine.
Need to quit jest watch and start again for the changes to be picked up correctly.
causes
My guess is that during rename, multiple files are affected and ts-jest only detect one file has been changed, so the cache of other files are not invalidated, thus containing outdated information.
This happens whenever I make changes to multiple files and save them at the same time.
Another example would be moving a type from one file to another.
Minimal repo
I encounter this in multiple situations. For example, https://github.com/unional/progress-str
To reproduce the issue, you need to run the test in watch mode (npm run watch in the repo above),
and then make some changes such as rename or move types.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 31
Commits related to this issue
- fix: disable ts-jest diagnostics for local tests. Due to: https://github.com/kulshekhar/ts-jest/issues/943 It happens quite often that hinders productivity — committed to unional/uni-cli by unional 5 years ago
- fix: burst cache when file’s deps change (#2167) Construct cache key with additional information is resolved module name + resolved module's last modified time. When one of imported modules of a file... — committed to kulshekhar/ts-jest by ahnpnl 4 years ago
- fix(compiler): retype check other files if processing file is used by those ones in watch mode (#2481) Closes #943 — committed to kulshekhar/ts-jest by ahnpnl 3 years ago
- Update dependency ts-jest to v29 (#110) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ts-jest](https://kulshekhar.github.io/ts-jest) ([source](htt... — committed to Vylpes/Droplet by deleted user a year ago
Also running into this issue with the most recent version of ts-jest (28.0.3), please consider reopening this issue until it is fixed. Thanks a lot.
Having this too. Might this issue be reopened ?
I have this issue too with
ts-jest 27.0.7Still seeing this on ts-jest 27.0.7 and jest 27.2.5. During watch,
ts-jestis throwing an error saying that a certain file doesn’t export a type, but it does. When I kill the watch and restart it, the issue is fixed.v27 😃 currently working on support jest 27 too. So when jest 27 is out,
ts-jestwill followI stumble upon of similar issue. And I guess I have an explanation of what’s going on.
As you may know TS type information only exists during development and removed upon compilation. Jest compiles files one by one and stores result in cache.
Now consider following example:
Run tests. All is OK. Jest will cache compiled File1 and File2.
Scenario 1:
Scenario 2:
Workaround: use --no-cache when running tests.
ts-jest
29.0.5here, same issueHi @ahnpnl , I’m not sure if this wasn’t actually fixed or if it is a regression. I recall this not being an issue a few months ago. There are some other issues related to this. Shall I create a new one? Or could you to reopen this?
What I experience is that type changes are not picked up anymore when running
jest --watch. Passing--no-cacheis not fixing it either. I’ve tested with the currently latest version27.0.7.omg i just had this problem, arrives here after googling, saw you fixed it 5 hours ago: awesome! 🎉
Seeing this issue as well. It’s really frustrating. I can even clear out a whole file that has types and it isn’t picked up.