Skip to content

feat: add yarn typecheck script#9109

Draft
cryptodev-2s wants to merge 1 commit into
MetaMask:mainfrom
cryptodev-2s:feat/typecheck-script
Draft

feat: add yarn typecheck script#9109
cryptodev-2s wants to merge 1 commit into
MetaMask:mainfrom
cryptodev-2s:feat/typecheck-script

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Explanation

yarn build:types excludes **/*.test.ts and ESLint doesn't surface TypeScript module-resolution errors, so test-file dangling import type declarations slip through CI — the gap that produced #8012.

This PR adds yarn typecheck (per-package + root fan-out) that runs tsc --noEmit over each package's dev tsconfig with test files included, so renames/removals of exported types are caught before merge.

To keep this to a single dev tsconfig per package (no parallel tsconfig.typecheck.json):

  • composite: true moves from tsconfig.base.jsontsconfig.packages.build.json (the only consumer was tsc --build tsconfig.build.json).
  • skipLibCheck: true added to tsconfig.base.json to match the build config.
  • Dev tsconfigs get references: [] (they were only meaningful under composite mode; build configs keep theirs intact).
  • core-backend dev tsconfig drops leftover outDir/rootDir.
  • typecheck script enforced across all non-private packages via yarn.config.cjs constraint.

Five test-file dangling-import bugs that the new script surfaced are fixed here too: account-tree-controller, multichain-account-service, ai-controllers, phishing-controller, multichain-network-controller.

The script is not wired into yarn lint yet — running yarn typecheck on main currently surfaces ~860 pre-existing errors across other packages, which need to be triaged by package owners before it can be CI-gating.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Tooling and test-only type/import fixes; no production runtime behavior changes. Large tsconfig churn is mechanical and build configs keep composite references.

Overview
Adds yarn typecheck at the repo root to fan out tsc --noEmit across non-private workspaces, with each package getting a matching typecheck script (enforced in yarn.config.cjs). Dev tsconfig.json files no longer use project references; composite and skipLibCheck are shifted so dev typechecking can include tests without a separate tsconfig.typecheck.json.

Several test-only fixes align with stricter checking: renamed snap messenger type import, KeyringCapabilities from @metamask/keyring-api/v2, digestId on AI digest mocks, XLM account type in multichain network tests, and an extra argument on AddressBookController:stateChange publish in phishing tests.

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

@cryptodev-2s cryptodev-2s requested review from a team as code owners June 12, 2026 12:09
@cryptodev-2s cryptodev-2s marked this pull request as draft June 12, 2026 12:11
@cryptodev-2s cryptodev-2s force-pushed the feat/typecheck-script branch from ab1374e to 63a6161 Compare June 12, 2026 12:16
Adds `yarn typecheck` (root + per-package) that runs `tsc --noEmit`
over each package's dev tsconfig, including test files. Closes the
gap where `yarn build:types` excluded `**/*.test.ts` and ESLint
doesn't surface module-resolution errors, letting test-file dangling
type imports through CI (see PR MetaMask#8012).

- Move `composite: true` from `tsconfig.base.json` to
  `tsconfig.packages.build.json` (the only consumer of project
  references is `tsc --build tsconfig.build.json`).
- Add `skipLibCheck: true` to `tsconfig.base.json` to match the
  build config and silence `node_modules` `.d.cts` noise.
- Clear `references: []` from per-package dev tsconfigs (they were
  only used by composite mode); build configs keep theirs.
- Strip leftover `outDir`/`rootDir` from `core-backend` dev tsconfig.
- Enforce per-package `typecheck` script via yarn constraints.
- Fix five test-file dangling type imports surfaced by the new
  script (account-tree, multichain-account-service, ai, phishing,
  multichain-network).
@cryptodev-2s cryptodev-2s force-pushed the feat/typecheck-script branch from 63a6161 to f0daa44 Compare June 12, 2026 12:16
@matthewwalsh0 matthewwalsh0 requested a review from jpuri June 12, 2026 13:26
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.

2 participants