radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
15.51k stars 791 forks source link

[Checkbox] export type CheckedState #2968

Closed bdsqqq closed 3 months ago

bdsqqq commented 3 months ago

Description

Adds back the export for the type CheckedState, it was exported in 1.0.* and used by some to make typesafe APIs that interact with Checkbox. But this export was removed in 1.1, now consumers need a type like: type CheckedState = Parameters<NonNullable<CheckboxProps['onCheckedChange']>>[0] to keep their APIs in sync with the Radix internal types.

rczobor commented 3 months ago

Could you add this type export to index.ts as well?

Also I think you'll have to run yarn version check --interactive, and then add patch version for checkbox.

vladmoroz commented 3 months ago

Surprised it actually worked before—I'm sure we never exported this type explicitly... In 1.1 there was a bundler change that might have affected the exports.

coffe4u commented 3 months ago

Is there any reason to not move forward with this? The upgrade to 1.1.0 fails for my application because of this issue.

Error: resources/assets/js/components/common/forms/checkbox-group/CheckboxGroup.tsx(2,15): error TS2459: Module '"@radix-ui/react-checkbox"' declares 'CheckedState' locally, but it is not exported.
Error: resources/assets/js/components/common/forms/checkbox-group/CheckboxGroup.types.ts(2,15): error TS2459: Module '"@radix-ui/react-checkbox"' declares 'CheckedState' locally, but it is not exported.
Error: resources/assets/js/components/common/forms/checkbox/Checkbox.stories.tsx(2,15): error TS2459: Module '"@radix-ui/react-checkbox"' declares 'CheckedState' locally, but it is not exported.
Error: resources/assets/js/components/common/forms/checkbox/Checkbox.types.ts(2,15): error TS245[9](https://github.com/Pairin/cps-staff-portal/actions/runs/9696086840/job/26757249212?pr=7941#step:6:10): Module '"@radix-ui/react-checkbox"' declares 'CheckedState' locally, but it is not exported.
bdsqqq commented 3 months ago

Closing since #2984 was merged