Skip to content

ref(scraps): Make radio group items type-safe - #130231

Merged
TkDodo merged 4 commits into
masterfrom
tkdodo/type-safe-tabs
Nov 10, 2026
Merged

TkDodo merged 4 commits into
masterfrom
tkdodo/type-safe-tabs

Conversation

@TkDodo

@TkDodo TkDodo commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

field.RadioGroup infers the allowed Item values and the onChange argument from its selected value. Invalid choices now fail type checking, and callers can pass field.handleChange without value casts.

<field.RadioGroup value={field.state.value} onChange={field.handleChange}>
  {({Item}) => (
    <field.Layout.Stack label="Priority">
      <Item value="low">Low</Item>
      <Item value="high">High</Item>
    </field.Layout.Stack>
  )}
</field.RadioGroup>

This replaces field.Radio.Group and field.Radio.Item

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-r26ejulq0.sentry.dev

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

decision-model-linter

voice

static/app/components/modals/sudoModal.tsx

  • warn usesTitleCaseInUiCopy = TRUE (0.77): Use sentence case for this title or label. Preserve the canonical spelling of product names, proper nouns, and acronyms.

decision-model-linter: 73 calls on 11 files, 137,908 input tokens, $0.0058, model typesafe/jev-1.13-20260917

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ no issues found

@priscilawebdev priscilawebdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

children: (components: {
Item: (props: RadioItemProps<NoInfer<T>>) => React.JSX.Element;
}) => React.ReactNode;
onChange: (value: NoInfer<T>) => void;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: is NoInfer needed here? On TS 6 value already wins inference over onChange, and Item is only used inside the callback, so it can't widen T either way

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it’s safer to infer from value only, e.g. if you have an onChange function that accepts a sub-set of values of a union

@TkDodo
TkDodo marked this pull request as ready for review November 10, 2026 11:46
@TkDodo
TkDodo requested review from a team as code owners November 10, 2026 11:46
@TkDodo
TkDodo enabled auto-merge (squash) November 10, 2026 11:48
@TkDodo
TkDodo merged commit a7cca04 into master Nov 10, 2026
83 checks passed
@TkDodo
TkDodo deleted the tkdodo/type-safe-tabs branch November 10, 2026 11:51
skaasten pushed a commit that referenced this pull request Nov 12, 2026
master replaced field.Radio.Group and field.Radio.Item with the
type-safe field.RadioGroup (#130231), so the project access radios
move to it and pass field.handleChange directly.

This branch was successfully deployed

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants