Skip to content

chore(jest): declare types: ['node', 'jest'] for TypeScript 6.0 compatibility#49

Merged
sjsyrek merged 1 commit intomainfrom
fix/jest-types-for-ts60
Apr 27, 2026
Merged

chore(jest): declare types: ['node', 'jest'] for TypeScript 6.0 compatibility#49
sjsyrek merged 1 commit intomainfrom
fix/jest-types-for-ts60

Conversation

@sjsyrek
Copy link
Copy Markdown
Contributor

@sjsyrek sjsyrek commented Apr 27, 2026

Summary

Pairs with #48 (already merged — rootDir fix). TypeScript 6.0 stopped auto-including all @types/* packages globally. The build is fine (src/ uses no jest globals), but the test compile breaks:

```
tests/setup.ts:10:1 - error TS2304: Cannot find name 'afterEach'.
tests/setup.ts:28:1 - error TS2304: Cannot find name 'afterAll'.
```

Adding `types: ['node', 'jest']` to the inline ts-jest `tsconfig` in `jest.config.js` (both the .ts and .js transformers) restores them.

Why this lives in jest.config.js, not tsconfig.json

`tsconfig.json` covers the src/-only build via `include: ["src/**/*"]`; src/ has no jest globals so it doesn't need the types declaration. The test transformer is the breakage point.

Backward Compatibility

Unchanged on TS 5.9.x. Verified:

  • `npm run lint` — clean on both TS 5.9.3 and TS 6.0.2
  • `npm run type-check` — clean on both
  • `npm test` — 5490 / 5490 tests pass on both

(TS 6.0 was tested locally via `npm install --no-save typescript@6.0.2`.)

Effect on #34

After this lands and dependabot rebases #34, that PR's CI should now pass: rootDir is resolved by #48 and jest globals are resolved here.

Size: Small ✓

4-line jest.config.js change.

🤖 Generated with Claude Code

TypeScript 6.0 stopped automatically including all @types/* packages
globally when the `types` compiler option is unset. Jest globals
(beforeAll, afterEach, afterAll, etc.) used in tests/setup.ts and
throughout the test suite stopped resolving:

  tests/setup.ts:10:1 - error TS2304: Cannot find name 'afterEach'.
  tests/setup.ts:28:1 - error TS2304: Cannot find name 'afterAll'.

The main tsconfig.json doesn't need this change because the build only
covers src/ (which uses no jest globals) and `skipLibCheck: true`
already mutes lib-level surprises. The fix lives in jest.config.js's
inline ts-jest tsconfig — both the .ts and .js transformers — because
that's what compiles the test files.

Verified on both currently-pinned TS 5.9.3 and the proposed TS 6.0.2
(via `--no-save` install): \`npm run lint\` clean, \`npm run type-check\`
clean, \`npm test\` 5490 / 5490 tests pass on each.

Unblocks dependabot PR #34 (typescript 5.9.3 → 6.0.2) — pairs with the
earlier #48 (rootDir) fix to complete TS 6.0 compatibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sjsyrek sjsyrek merged commit 92ae3c2 into main Apr 27, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

1 participant