#2707·ts-jest

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

Author: drrnkinCreated Jun 29, 2021Updated Dec 22, 2025
Labels:bug: BugConfirmed

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