Skip to content

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

Open
cryptodev-2s wants to merge 1 commit into
migrate/es2022from
migrate/typecheck-tests
Open

chore: type check tests via lint:tsc#334
cryptodev-2s wants to merge 1 commit into
migrate/es2022from
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
Lint-only tooling; no runtime or published API behavior changes.

Overview
Adds yarn lint:tsc (tsc --noEmit against a new tsconfig.lint.json) and runs it first in yarn lint, so Jest/ts-jest test files and other non-build TypeScript actually get type-checked during CI and local lint (build and transpile-only tests did not cover them).

tsconfig.lint.json extends the root config with skipLibCheck and excludes dist and *.test-d.ts so dependency .d.ts noise and tsd-owned declaration tests stay out of this pass while yarn test:types still handles the latter.

Reviewed by Cursor Bugbot for commit 2caaa71. 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.

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