You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keep typed Vite configs and type-aware lint rules working with redact(). Thanks to @WolfieLeader for reporting this.
AI review notes:
The factory now returns its inferred plugin array and checks it against Vite's plugin contract. Literal hook ordering stays typed, newer environment hooks stay visible, and public declarations avoid an optional Vite type dependency. This also avoids the duplicate Node declaration failure found with a direct Plugin[] annotation.
The built-declaration regression rejects the old any signature and checks both exports, nested plugin arrays and spread usage. Full local CI passed: 2,128 tests, 91 skipped, types, strict build verification and all 38 fixed size caps. All 36 comparisons against current main are unchanged. Clean consumers passed with Vite 5.4.21, 6.4.6, 7.3.8 and 8.3.5, TypeScript 5.9.3 and skipLibCheck: false.
No runtime dependencies, workflows or budget limits changed. Existing tests use the same partial-context hook harness pattern as the other Vite tests.
CI follow-up:
The development HMR check failed after restoring a route file, with a missing server context and lost counter state. A controlled 200 ms incomplete write also broke the unchanged fixture with native React. The fixture now uses Vite's supported completed-write watcher mode, with no assertion or timeout changes.
The controlled write passes for native React and Redact on Chromium, Firefox and WebKit. The ordinary development and production checks also pass on all three engines. Local container copies only adapt Chromium's launch sandbox setting for the existing isolated root container; the shipped script is unchanged. This verifies the reproduced incomplete-write case, the original hosted missing-context outcome still needs the normal CI rerun. The package source and all measured size rows remain unchanged.
Summary by CodeRabbit
Bug Fixes
redact() now returns Vite plugins with usable TypeScript types instead of any.
Improved fixture stability when reading updated modules during hot reload.
No actionable comments were generated in the recent review.
Walkthrough
The Vite redact() function now infers its plugin-array return type and checks the array against Vite’s Plugin type. Tests check the built declaration’s types, locate plugins with a shared helper, and configure file-write polling in a fixture.
Changes: Vite return typing
Layer / File(s)
Summary
Infer and check the plugin array packages/redact/src/vite/index.ts, .changeset/typed-vite-plugin.md
redact() now returns an inferred plugin array checked with satisfies Array<Plugin>. Literal enforce and order values use as const. The changeset describes the return-type update.
Validate plugin typing and selection tests/vite-plugin-types.test.ts, tests/vite-environments.test.ts, tests/fixtures/react-router-framework/vite.config.js
A consumer test checks the built declaration’s return types and Vite config compatibility. Environment tests use a shared helper to find named plugins. The fixture server polls for file-write completion before HMR reads updated modules.
This change makes the Vite plugin return a typed plugin array instead of any, with tests covering the built declaration. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title 'fix(vite): preserve typed plugin return values' matches the main change. The changeset and the redact() source change make the inferred plugin array the return type instead of any, and a ne…
Linked Issues check
Only directly linked issue #185 applies. Its coding requirement is that redact() from @tanstack/redact/vite stop returning any, so typed Vite configs keep plugin checking. The previous review fo…
Out of Scope Changes check
The incremental change since the previous review adds a watcher option (server.watch.awaitWriteFinish with stabilityThreshold: 300 and pollInterval: 10) to the React Router framework fixture's V…
Full details: Title check
Explanation
The title 'fix(vite): preserve typed plugin return values' matches the main change. The changeset and the redact() source change make the inferred plugin array the return type instead of any, and a new test checks that the declared return type is not any and is assignable to Plugin[]. The title names the scope (vite) and the fix (typed return values). It does not mention the HMR fixture change, which is a minor follow-up and not the primary change.
Full details: Linked Issues check
Explanation
Only directly linked issue #185 applies. Its coding requirement is that redact() from @tanstack/redact/vite stop returning any, so typed Vite configs keep plugin checking. The previous review found this met at the reviewed head: the : any return annotation is removed, the function returns an inferred plugin array, and return plugins satisfies Array<Plugin> checks the array against Vite's Plugin type. enforce and order use as const, and applyToEnvironment and filter stay in the inferred shape. The incremental diff from the previous reviewed head (41e99a9) to head (f13c883) changes only tests/fixtures/react-router-framework/vite.config.js. It does not touch the source or declaration code, so the prior conclusion still holds. The new tests/vite-plugin-types.test.ts checks the built declaration, but it does not exercise the no-unsafe-assignment lint rule directly. PR-reported CI and Vite-version consumer results were not re-run in this review.
Full details: Out of Scope Changes check
Explanation
The incremental change since the previous review adds a watcher option (server.watch.awaitWriteFinish with stabilityThreshold: 300 and pollInterval: 10) to the React Router framework fixture's Vite config. It is test-fixture configuration only, with no runtime package change. The PR description and objectives describe this as a CI follow-up for the HMR fixture, so it is part of the stated PR scope, although it is not directly tied to #185. The earlier in-scope changes (source typing, tests/vite-plugin-types.test.ts, tests/vite-environments.test.ts helper, and the changeset) remain connected to #185. No demonstrated unrelated change was found.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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
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.
Keep typed Vite configs and type-aware lint rules working with
redact(). Thanks to @WolfieLeader for reporting this.Fixes #185
Summary by CodeRabbit
redact()now returns Vite plugins with usable TypeScript types instead ofany.