Configure TypeScript typecheck for type-drift detection#596
Merged
Conversation
Vitest's `--typecheck` engine built its tsc program from the root `tsconfig.json`, which has no `include` and therefore swept the entire monorepo's source. Example UI `.tsx` files (which need `jsx`) and provider packages relying on their own ambient `types`/`lib` (Chrome AI, Cloudflare) then surfaced hundreds of "unhandled source errors" unrelated to the drift guard, failing the nightly even though the 3 drift tests passed. Point vitest's typecheck at a dedicated `tsconfig.typecheck.json` scoped to `packages/ai/src`, so the program only contains the file under test and resolves cross-package imports to the already-built `.d.ts` declarations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6ie5uJvfMpFZrGtrKL1c4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds TypeScript typecheck configuration for Vitest to enable type-drift detection in
.test-d.tsfiles. This isolates the type-checking scope to thepackages/aipackage to prevent unrelated source code (example UIs, provider ambient types) from being swept into type-checking reports.Changes
noEmit: trueand scopes type-checking topackages/ai/src/**/*typecheckconfiguration block that references the newtsconfig.typecheck.json, with explanatory comment about the nightly type-drift guard and why the scope is limited to the package under testImplementation Details
The typecheck configuration disables composite and incremental compilation modes while enabling
noEmitto ensure Vitest's--typecheckengine only validates types without generating output. By explicitly including onlypackages/ai/src/**/*and excludingdistandnode_modules, the configuration prevents type-checking from inadvertently reporting drift in unrelated packages that may have their own type requirements (e.g., JSX in example UIs, ambient type declarations in provider packages).https://claude.ai/code/session_01G6ie5uJvfMpFZrGtrKL1c4