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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

With cached results, changes to type definitions are not detected between packages #2707

Open
drrnkin opened this issue Jun 29, 2021 · 4 comments
Labels
馃悰 Bug Confirmed Bug is confirmed

Comments

@drrnkin
Copy link

drrnkin commented Jun 29, 2021

馃悰 Bug Report

When a typescript package is compiled with type info, changes to the type info may be missed by ts-jest when the package is referenced from another package. Similar to #1747 but not identical.

To Reproduce

Steps to reproduce the behavior:
Unzip the attached zip file and follow the README.txt, which is copied inline here:

In the examplePackage folder, run:
yarn
yarn build
yarn link

In the consumerWithTest folder, run:
yarn
yarn link @example/package
yarn test

So far so good (the jestCache folder is created).
Now edit index.ts to uncomment b: number; and in the examplePackage folder, run:
yarn build

In the consumerWithTest folder, run:
yarn test

This should fail due to the change in type definition in index.ts, but passes.
Running yarn test --no-cache correctly identifies the problem.

jestCacheIssue.zip

Expected behavior

Type info should be respected without clearing the cache

Link to repo (highly encouraged)

Debug log:

# content of ts-jest.log :

envinfo

System:
    OS: Windows 10
    Node version: v14.16.1

Npm packages:
    jest: (included in zip) 27.0.6
    ts-jest: (included in zip) 27.0.3
    typescript: (included in zip) 4.3.4
@drrnkin drrnkin added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Jun 29, 2021
@drrnkin
Copy link
Author

drrnkin commented Jul 12, 2021

Hi @ahnpnl. Other than the mention in #2696, I haven't seen any official acknowledgement of this bug. The other bug mentioned a design choice. Does that mean a significant redesign is in the works?

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jul 12, 2021

I would say yes, it鈥檚 quite a change, generally speaking is: moving type check to one phase earlier in transform process.

The current design is: collecting all dependencies to construct cache keys and let Jest handle when a file needs to be rechecked.

What I have in mind for a design change is: instead of letting Jest handle, we would always do type check before creating a Jest cache key (ofc only do this when user uses cache). Following this approach will technically solve issues but probably require a smart way of caching for ts-jest so that we only do type check for files which have been changed or when its dependencies have been changed.

@ahnpnl ahnpnl added 馃悰 Bug Confirmed Bug is confirmed and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Jul 12, 2021
@drrnkin
Copy link
Author

drrnkin commented Jan 13, 2022

Is there any ETA on when this bug might be fixed? Our team keeps experiencing it and it's quite costly for us.

@drrnkin
Copy link
Author

drrnkin commented Aug 21, 2022

For the record, I ended up working around this. I changed our build scripts to compile our test code with the TS compiler, not just the product code. We still use ts-jest to run the tests but the cache bug won't affect us because compilation errors are caught by the TS compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 Bug Confirmed Bug is confirmed
Projects
None yet
Development

No branches or pull requests

2 participants