fix(plugin-view): coerce i18n tab-label helpers to string (TS2322)#2721
Merged
Conversation
`useViewTabLabel()` (ViewTabBar) and `useViewLabel()` (ManageViewsDialog) returned the raw `t()` result, typed `string | object` by i18next. Their return values are rendered directly as React children and passed as aria-labels at ~35 sites, so vite build's dts pass emitted TS2322 (`string | object` not assignable to ReactNode). plugin-view has no type-check gate, so these did not fail the build — but if `t()` ever resolves a key to an object, React throws and white-screens. Coerce the resolved value with `String(v)` and annotate the helper's return type as `string`. Same "i18n/expression value is string|object, rendered raw → white-screen" class tracked separately from PR #2718. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
What
useViewTabLabel()inViewTabBar.tsxand the identicaluseViewLabel()inManageViewsDialog.tsxreturned the rawt()result. i18next typest()asstring | object(it can resolve a key to an object), so the helper's return type wasstring | object.That value is rendered directly as a React child and passed as
aria-labelat ~35 call sites, sovite build's declaration-generation (dts) pass emittederror TS2322: Type 'string | object' is not assignable to type 'ReactNode'(and tostring | undefinedfor aria-labels).Because
plugin-viewbuilds withvite build(no type-check gate), these did not fail the build — but they are real: ift()ever resolves a key to an object, React throws and white-screens. This is the known "i18n/expression value isstring | object, rendered raw → white-screen" class.Fix
Coerce the resolved value with
String(v)and annotate the helper return type asstring, in both helpers. Behavior-preserving for the normal (string) case.Scope
The task named
ViewTabBar.tsx; while verifying at the package level, thevite builddts pass surfaced the identical bug (22 TS2322s) in the siblingManageViewsDialog.tsx— same copied helper, same root cause, same package. Fixed both so the package is clean of this class. Out of scope for the docs-build fix in #2718; tracked separately.Verification
pnpm --filter @object-ui/plugin-view build— before: TS2322 from both files; after: noTS2322/error TS, declaration files build cleanly,✓ built.eslinton both files reports only pre-existing warnings/errors (conditional hook,vars as any,Functiontype, setState-in-effect) — none introduced by this change.🤖 Generated with Claude Code