nasheomirro / react-polymorphed

A set of types to help easily create fast polymorphic components.
MIT License
24 stars 3 forks source link

Incorrect props when dealing with Union Types #1

Closed nasheomirro closed 1 year ago

nasheomirro commented 1 year ago

Missing props when passed a component that has a union type as props:

import React from 'react';
import { PolymorphicComponent } from 'index';

type ITestA = {
  value: "a";
  extra: string;
}

type ITestB = {
  value: "b";
}

type Test = ITestA | ITestB;
const Test = {} as React.FC<Test>;
const Button = {} as PolymorphicComponent<"button">;
// extra is missing
<Button as={Test} value="a" />

extra should still be required but is omitted from props.