Skip to content

chore: type check tests via lint:tsc - #334

Merged
cryptodev-2s merged 4 commits into
mainfrom
migrate/typecheck-tests
Sep 10, 2026
Merged

chore: type check tests via lint:tsc#334
cryptodev-2s merged 4 commits into
mainfrom
migrate/typecheck-tests

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Top of stack #331, on #333. Opts this package into the progressive test type checking rollout core is doing (16 of its 100 packages so far).

Tests were not type checked at all

Verified by injecting const deliberateTypeError: number = "a string" into a test file:

Check Result
yarn build passes, tsconfig.build.json excludes tests
yarn test:source passes, see below
yarn test:types passes, tsd only reads *.test-d.ts
yarn lint passes

test:source can never catch it: isolatedModules puts ts-jest on its transpileModule path, which erases types without checking them.

The change

lint:tsc = tsc --noEmit --project tsconfig.lint.json     ← added to `lint`

tsconfig.lint.json extends tsconfig.json (which already covers everything the build does not) and adds skipLibCheck, because dependency declarations do not satisfy the strict flags used here.

Why *.test-d.ts is excluded

Those belong to tsd, which checks them itself via yarn test:types (fixed in #322). Including them here pulls tsd's own types into the program, and those reach type-fest, whose basic.d.ts carries /// <reference lib="esnext" />. That silently widens built in types past this package's lib, producing a spurious failure where FrozenSet no longer satisfies ReadonlySet because of Set methods we do not target. Traced with tsc --explainFiles.

Why this stacks on ES2022

With lib: ES2020 a tsc pass over the tests reports 11 errors, nearly all Property 'cause' does not exist. With lib: ES2022, zero. #333 has to land first.

Confirmed not vacuous

A deliberate type error in a test file now exits non-zero with TS2322, and tsd still independently catches a bad expectAssignable in a .test-d.ts file.


Note

Low Risk
Dev-only lint and TypeScript config changes; no runtime or shipped library behavior changes.

Overview
yarn lint now runs TypeScript on test and other non-build code through a new lint:tsc script, closing a gap where tsconfig.build.json and transpile-only Jest never validated types in *.test.ts files.

A new tsconfig.lint.json extends the root config with skipLibCheck, incremental emitDeclarationOnly output under .tsc-lint-cache/ (gitignored and ignored by ESLint), and an exclude for *.test-d.ts so tsd-owned type tests are not double-checked or polluted by tsd’s wider lib types.

Reviewed by Cursor Bugbot for commit 670fa8a. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s added this pull request to stack #331 September 9, 2026 20:40
@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

The following preview build has been published:

@metamask-previews/utils@11.12.1-preview-2caaa71

Learn how to use preview builds in other projects.

Mrtenz
Mrtenz previously approved these changes Sep 10, 2026
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 2caaa71 to 2944d37 Compare September 10, 2026 09:32
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 2944d37 to 6c941c7 Compare September 10, 2026 10:15
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 6c941c7 to 5b0357e Compare September 10, 2026 10:28
@cryptodev-2s
cryptodev-2s removed this pull request from stack #331 September 10, 2026 10:40
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 5b0357e to 4bb3dbb Compare September 10, 2026 10:41
@cryptodev-2s
cryptodev-2s added this pull request to stack #335 September 10, 2026 10:41
@cryptodev-2s
cryptodev-2s requested a review from Mrtenz September 10, 2026 10:47
@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

The following preview build has been published:

@metamask-previews/utils@11.12.1-preview-4bb3dbb

Learn how to use preview builds in other projects.

@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 4bb3dbb to 30e7dd6 Compare September 10, 2026 11:05
Mrtenz
Mrtenz previously approved these changes Sep 10, 2026
stack merge was automatically disabled September 10, 2026 11:16

Pull Request is not mergeable

stack merge was automatically disabled September 10, 2026 11:20

Pull Request is not mergeable

stack merge was automatically disabled September 10, 2026 11:35

Pull Request is not mergeable

stack merge was automatically disabled September 10, 2026 11:51

Pull Request is not mergeable

stack merge was automatically disabled September 10, 2026 12:14

Pull Request is not mergeable

@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 30e7dd6 to f5c48f4 Compare September 10, 2026 12:46
stack merge was automatically disabled September 10, 2026 13:00

Pull Request is not mergeable

@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from f5c48f4 to 525ef27 Compare September 10, 2026 13:03
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 525ef27 to 36992e5 Compare September 10, 2026 13:08
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 36992e5 to 7030f20 Compare September 10, 2026 13:15
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 7030f20 to 6864031 Compare September 10, 2026 13:21
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 6864031 to cc0baf4 Compare September 10, 2026 13:27
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from cc0baf4 to 57e45b2 Compare September 10, 2026 13:33
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 57e45b2 to ac81167 Compare September 10, 2026 13:40
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from ac81167 to 5426901 Compare September 10, 2026 13:50
Base automatically changed from migrate/es2022 to main September 10, 2026 13:54
@cryptodev-2s
cryptodev-2s force-pushed the migrate/typecheck-tests branch from 5426901 to 35af027 Compare September 10, 2026 13:54
Comment thread package.json Outdated
Comment thread tsconfig.lint.json Outdated
@cryptodev-2s
cryptodev-2s requested a review from mcmire September 10, 2026 14:43

@mcmire mcmire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cryptodev-2s
cryptodev-2s merged commit 212cb5c into main Sep 10, 2026
19 checks passed
@cryptodev-2s
cryptodev-2s deleted the migrate/typecheck-tests branch September 10, 2026 14:55
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.

3 participants