Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clear-beds-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-polymorphic": patch
---

Fix `Inherit` required-prop behavior to preserve inherited `undefined` unions when converting optional inherited props to required.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-polymorphic",
"version": "1.0.1",
"version": "1.0.2",
"description": "Create polymorphic React 19+ components with strong TypeScript inference.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion src/createPolymorph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type RequiredKeys<T> = {
/** Sets all keys in `K` of type `T` to required. */
type Require<T, K extends PropertyKey> = Overwrite<
T,
Required<Pick<T, K extends keyof T ? K : never>>
{ [P in Extract<K, keyof T>]: T[P] }
>;

// Tag ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/createPolymorph/config.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ComponentE = createPolymorph<
>(({ as: Tag = 'div', className, ...rest }) => {
return (
<Tag
className={typeof className === 'string' ? className : className()}
className={typeof className === 'function' ? className() : className}
{...rest}
/>
);
Expand Down
1 change: 1 addition & 0 deletions tests/types/createPolymorph/Inherit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ type _ = [
true
>
>,
Assert<IsEqual<P['onClick'], ComponentProps<'button'>['onClick']>>,
Assert<IsEqual<IsOptionalKey<P, 'onClick'>, false>>
];
Loading