kripod / kripod/react-polymorphic-box
Incorrect work with Unions Types
- Dominant language
- TypeScript
- Stars
- 346
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Polymorphic box has partialized props if "as" component has unioned props.
## Reproduction
```
import React from 'react';
import { Box } from 'react-polymorphic-box';
interface ITestA {
value: 'a';
}
interface ITestB {
value: 'b';
extra: string;
}
type Test = ITestA | ITestB;
const Test: React.FC = (props) => {
return <>;
};
function App() {
return (
<>
);
}
```
## Expected behavior
Polymorphic box has correct props types.
## Actual behavior

>`Type '{ as: FC; value: "b"; extra: string; }' is not assignable to type 'IntrinsicAttributes & BoxOwnProps> & Pick, "value" | "children">'.
Property 'extra' does not exist on type 'IntrinsicAttributes & BoxOwnProps> & Pick, "value" | "children">'`
Contributor guide
Research direction
Start by compiling the TypeScript reproduction using the Box component and the unioned Test props shown in the issue. Compare the props accepted by Test directly with those accepted through Box; the work is done when the Box usage accepts value="b" and extra="extra" with correct TypeScript types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100