chore(jest): declare types: ['node', 'jest'] for TypeScript 6.0 compatibility#49
Merged
chore(jest): declare types: ['node', 'jest'] for TypeScript 6.0 compatibility#49
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pairs with #48 (already merged —
rootDirfix). 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:
(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