MetaMask / MetaMask/metamask-extension
Migrate type-level tests to tstyche
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
## Summary
Migrate the custom type-level tests (`.proof.ts` files) that were introduced in PR #40680 to use [tstyche](https://github.com/tstyche/tstyche), a dedicated type-testing framework.
## Context
PR #40680 ([fix: Make mmLazy polymorphic with inference of imported component types](https://github.com/MetaMask/metamask-extension/pull/40680)) added type-level tests for `InferComponent` and `mmLazy` generic type inference. These tests use a custom `Expect<>` type assertion pattern in `*.proof.ts` files (e.g., `ui/helpers/utils/mm-lazy.proof.ts`).
During review, [mcmire suggested](https://github.com/MetaMask/metamask-extension/pull/40680#discussion_r0) using tstyche or tsd instead of the custom approach. The author indicated they would look into tstyche.
## Current approach
- Custom `Expect` type in `shared/types/type-test-utils.ts`
- Compile-time assertions via `Expect, ExpectedType>` in `.proof.ts` files
- Type errors surface failures when `tsc` runs
## Proposed approach
- Add tstyche as a dev dependency
- Migrate existing `.proof.ts` tests to tstyche's type-test syntax
- Remove or repurpose the custom `Expect` / `type-test-utils` if they become redundant
- Standardize on tstyche for future type-level tests
## Benefits
- Standard tooling with community support and documentation
- Better discoverability for contributors (e.g., `yarn test:types` or similar)
- Potential for value-level type tests alongside pure type-level tests
- Easier maintenance and fewer custom abstractions
## References
- [PR #40680](https://github.com/MetaMask/metamask-extension/pull/40680) — mmLazy polymorphic types + initial proof tests
- [tstyche](https://github.com/tstyche/tstyche) — TypeScript type testing framework
- [tsd](https://github.com/SamVerschueren/tsd) — alternative (mentioned in PR review)
## Acceptance criteria
- [ ] tstyche added as dev dependency
- [ ] `mm-lazy.proof.ts` (and any other `.proof.ts` files) migrated to tstyche
- [ ] Type tests run in CI (e.g., as part of `test:tsc` or a dedicated `test:types` step)
- [ ] Custom `Expect` / type-test utilities removed or documented as deprecated if still needed
- [ ] Documentation updated (e.g., CONTRIBUTING, AGENTS.md) for writing type-level tests
Contributor guide
Research direction
Start with ui/helpers/utils/mm-lazy.proof.ts and the other *.proof.ts files, then inspect shared/types/type-test-utils.ts and the existing test:tsc setup. Determine how tstyche should run in CI and whether the custom Expect utility is still needed. Done means the type tests use tstyche, run in CI, and the relevant contributor documentation is updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100