Skip to content

feat(typecheck): support static type testing - #1984

Draft
9aoy wants to merge 4 commits into
mainfrom
9aoy/feat-type-testing
Draft

9aoy wants to merge 4 commits into
mainfrom
9aoy/feat-type-testing

Conversation

@9aoy

@9aoy 9aoy commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Runtime assertions cannot verify inferred API types or published declarations. Add static type tests to Rstest's discovery and reporting flow without making ordinary runtime users install the type-testing implementation.

Changes

  • Add the optional, version-locked @rstest/typecheck package, loaded through a core-owned executor contract like browser mode. Core retains configuration, discovery and run finalization; missing or mismatched packages produce installation guidance.
  • Export lightweight test, it, describe, assertType and expectTypeOf APIs from the new package. Its public declarations do not load core, Rsbuild or Rspack configuration types. Existing core registration imports remain recognized. Type assertions are explicit imports from the new package.
  • Use Yuku to collect original TypeScript without execution, including aliases, namespace imports, lexical shadowing, nested cases and UTF-16 locations. Remove Babel parser/traverse from the type-testing implementation and core dependencies.
  • Invoke the project's official tsc or vue-tsc CLI once per project (TypeScript 6 and 7 supported). The same invocation returns diagnostics and checked inputs, disables emission, overrides noCheck, and reuses incremental disk results. Filters never hide whole-project diagnostics.
  • Share --onlyFailures selection and failure history across runtime and type tests. Finalize writes the cache once, preserving it for partial or bail-aborted runs. bail stops later type cases and subsequent project checks while each compiler invocation still checks its full project.
  • Integrate run/list and the instance API, sharding, reporters and blob results. Browser projects check types on the host without launching a browser. Watch mode, .only, .skip, parameterized/conditional modifiers and dynamic registration are unsupported.
  • Migrate e2e/types, add package-loading and declaration-dependency regression tests, and update English/Chinese docs. Rspack aliases remain separate from TypeScript resolution; no adapter translation is needed.

Editor companion: rstackjs/rstack-editor#111

Validation on macOS: full workspace build; 1,691 unit tests passed; 45 relevant type/selection/cache/bail/browser e2e tests passed, 3 headed tests skipped; lint/typecheck, unused-code checks and all pre-push checks passed. TypeScript 6.0.3, TypeScript 7.0.2 and vue-tsc 3.3.13 each passed valid → invalid → fixed assertions, including inherited noCheck: true. TypeScript 6 and 7 also passed full failure → bail → fixed-onlyFailures CLI runs. Windows/Linux execution remains for CI.

Pure type-test benchmark (measured at d6d2100, before the failure-history integration): Node 24.11.1 on Apple M4 Max, Vitest 5.0.5, 10 cases per file and 5 assertions per case. Identical workloads except the framework import: @rstest/typecheck versus vitest. Five sequential paired repeats per configuration, alternating framework order (120 runs); all case counts verified. Cold removes compiler/framework disk caches, retaining OS caches; warm uses a fresh CLI process with the previous cold run's cache. Median seconds below; background desktop processes were not stopped.

Cases Compiler Rstest cold Vitest cold Rstest warm Vitest warm
100 TS6 0.539 0.647 0.287 0.378
100 TS7 0.227 0.283 0.183 0.244
1,000 TS6 2.054 2.209 0.353 0.551
1,000 TS7 0.490 0.626 0.186 0.370
5,000 TS6 9.313 10.105 0.622 1.343
5,000 TS7 2.046 2.387 0.346 0.978

At 1,000 cases, the new entry loads 171 compiler inputs (70 declarations), versus Vitest's 190 (89 declarations); the earlier core-entry measurement loaded 553. Tests of core's own published API continue importing the real core entry rather than a substituted declaration.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: f33b9d7
Status: ✅  Deploy successful!
Preview URL: https://98100fdf.rstest.pages.dev
Branch Preview URL: https://9aoy-feat-type-testing.rstest.pages.dev

View logs

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 13 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
adapter-rsbuild 6.1 KB 2.0 KB 0 0
adapter-rslib 51.1 KB 13.5 KB 0 0
browser 1.2 MB 328.2 KB 0 0
adapter-rspack 12.4 KB 2.9 KB 0 0
browser-react 7.2 KB 1.4 KB 0 0
coverage-istanbul 23.0 KB 5.1 KB 0 0
playwright 54.0 KB 11.6 KB 0 0
coverage-v8 85.9 KB 16.0 KB 0 0
browser/client 92.2 KB 13.1 KB 0 0
core/browser 661.4 KB 187.9 KB +986.0 B (0.1%) +319.0 B (0.2%)
core/main 2.1 MB 552.2 KB +12.9 KB (0.6%) +3.7 KB (0.7%)
vscode/extension 1.1 MB 83.3 KB 0 0
vscode/worker 19.2 KB 5.0 KB 0 0
📋 Detailed Reports (Click to expand)

📁 core/browser

Path: packages/core/.rsdoctor/browser/rsdoctor-data.json

📌 Baseline Commit: 9e3cb98a3d3dd39e58d83f41cd76e593cdb5b637 | PR: #1983

Metric Current Baseline Change
📊 Total Size 661.4 KB 660.4 KB +986.0 B (0.1%)
🗜️ Gzip Size 187.9 KB 187.6 KB +319.0 B (0.2%)
📄 JavaScript 489.6 KB 489.6 KB 0
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 171.7 KB 170.8 KB +986.0 B (0.6%)

📦 Download Diff Report: core/browser Bundle Diff

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: 9e3cb98a3d3dd39e58d83f41cd76e593cdb5b637 | PR: #1983

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB +12.9 KB (0.6%)
🗜️ Gzip Size 552.2 KB 548.6 KB +3.7 KB (0.7%)
📄 JavaScript 1.7 MB 1.7 MB +10.2 KB (0.6%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 450.7 KB 448.0 KB +2.7 KB (0.6%)

📦 Download Diff Report: core/main Bundle Diff

Generated by Rsdoctor GitHub Action

@9aoy 9aoy changed the title feat(core): support type testing feat(typecheck): support static type testing Oct 22, 2026

This branch has not been deployed

No deployments
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

⌂ 换网址