Skip to content

test(lab): MobileTokenizer's create harness types its spy as a callable - #8313

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c09-mobiletokenizer-spy-type
Oct 25, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c09-mobiletokenizer-spy-type

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

User impact

Contributors running pnpm -F @astryxdesign/lab typecheck on main get one error, so the package's typecheck can't be used as a clean gate:

src/MobileTokenizer/MobileTokenizer.test.tsx(70,9): error TS2348: Value of type 'Mock<Procedure | Constructable>' is not callable. Did you mean to include 'new'?

Problem and solution fit

  1. Why it occurs: the create harness types its spy as ReturnType<typeof vi.fn>, which vitest 4.1 types as Mock<Procedure | Constructable>, a union TypeScript won't call, and the harness calls spy(items, change).
  2. Why it harms the task: lab's typecheck fails on a clean checkout, which hides real type errors behind a known one.
  3. Why it matters: CI runs lab's typecheck:docs but not its typecheck, so the error went unnoticed; any branch that runs the full typecheck inherits it.

The harness now types its spy with the same callable signature as the file's other harness; vi.fn() still fits it.

Expected behavior and authority

pnpm -F @astryxdesign/lab typecheck passes on a clean checkout, like the other packages' typechecks.

Smallest restoration

One type annotation in one test file. No runtime, API or test behavior change.

Evidence

  • Reproduction before the change: on main (2763bcc) with core built, pnpm -F @astryxdesign/lab typecheck exits 2 with the TS2348 error above, its only error.
  • Result after the change: it exits 0.
  • Representative unchanged path: the MobileTokenizer tests (10) pass as before.
  • Regression test or other mutation-sensitive proof: the typecheck itself; reverting the annotation brings TS2348 back.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm -F @astryxdesign/core build, then pnpm -F @astryxdesign/lab typecheck: 0 errors (main: 1, TS2348).
  • pnpm exec vitest run packages/lab/src/MobileTokenizer: 1 file, 10 tests passed.
  • node scripts/release/changeset-coverage.mjs pr: nothing here ships to consumers, so no Changeset.
  • ESLint and Prettier on the touched file.

`pnpm -F @astryxdesign/lab typecheck` failed on main: the create harness
typed its spy as `ReturnType<typeof vi.fn>`, which vitest 4.1 types as
`Mock<Procedure | Constructable>`, a mock TypeScript won't call
(`spy(items, change)`: TS2348). The harness now takes the same callable
type as the file's other harness; `vi.fn()` still fits it.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 10:25pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 10:48 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026

@astracat-bot astracat-bot Bot 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.

No changes requested: typing CreateHarness's spy with the same callable signature as Harness clears the TS2348 error, so pnpm -F @astryxdesign/lab typecheck passes and the MobileTokenizer tests still pass. Nothing further is needed from you.

[Automated review]

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

MobileTokenizer (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Entry File (ESM) 328B 328B 0B
Lines of Code 598 598 -
Complexity Very High Very High (64) -

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/lab 4.6KB 1.9KB 1.9KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

cixzhang pushed a commit that referenced this pull request Oct 25, 2026
…core (#8318)

Depends on #8313: until it merges, this branch carries its commit, and lab's typecheck needs it. Review the last commit.

## Maintainer impact

A type error in the sources or tests of `@astryxdesign/lab`, `charts`, `richtext` or `vega` merges without a red check. CI's `typecheck` job and the push gate's `typecheck` lane run only these packages' `typecheck:docs`, which covers their `.doc.mjs` files; core alone also runs its full `typecheck`. Lab's `MobileTokenizer.test.tsx` merged with an error this way (TS2348, fixed in #8313), and anyone running `pnpm -F @astryxdesign/lab typecheck` hit it on main.

## Intended invariant

Every component package's own sources and tests typecheck in both typecheck lanes, as core's do since #3197: a type error fails the required `build` join (and the release check) instead of landing on main.

## Change

- `ci.yml` `typecheck` job: `Typecheck lab / charts / rich text / Vega (including tests)` after `Typecheck core (including tests)`, with the same specialized-lane guard. No new job, scope or join: `typecheck` already runs for every non-specialized change and feeds `build`.
- `deploy.yml` `typecheck` lane: the same four gates after core's.
- `ci-test-routing.test.mjs`: both workflows must run `pnpm -F @astryxdesign/<package> typecheck` (the exact command, so `typecheck:docs` does not count) for core, lab, charts, richtext and vega, guarded like core's.

Cost: 1–8 s per package on a large machine. The `typecheck` job (about 4.5 min, mostly the build) runs beside `build-storybook` and stays off the critical path.

## Evidence

- Failure before the change: the new routing cases fail on main's workflows ("ci.yml does not typecheck lab", and the same for deploy.yml). On main, `pnpm -F @astryxdesign/lab typecheck` exits 2.
- Success after the change: with #8313, all four typechecks pass after `pnpm build` (lab 8 s, charts 2 s, rich text 5 s, Vega 1 s); the routing cases pass.
- Product/runtime behavior verified unchanged: workflow and test files only.

## Scope

- [x] No intended public API, product behavior, visual direction, or policy change.
- [x] Product changes discovered during the work were removed or split.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- `pnpm exec vitest run .github/scripts`: 1,229 passed; with the workflow edits reverted, the two new cases fail.
- `pnpm build`, then `pnpm -F @astryxdesign/{lab,charts,richtext,vega} typecheck`: all exit 0.
- Prettier on the touched files and the pre-commit repo checks: clean.
@cixzhang
cixzhang merged commit aa3b92f into meta:main Oct 25, 2026
60 checks passed
@vjeux
vjeux deleted the uikit/c09-mobiletokenizer-spy-type branch October 25, 2026 02:58

This branch was successfully deployed

1 active deployment
Preview — 2e0ba8fe Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants