Skip to content

Incorrect work with Unions Types #23

@SiarheiLazakovich

Description

@SiarheiLazakovich

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<Test> = (props) => {
  return <></>;
};

function App() {
  return (
    <>
      <Test value="b" extra="extra" />
      <Box as={Test} value="b" extra="extra" />
    </>
  );
}

Expected behavior

Polymorphic box has correct props types.

Actual behavior

Type '{ as: FC<Test>; value: "b"; extra: string; }' is not assignable to type 'IntrinsicAttributes & BoxOwnProps<FC<Test>> & Pick<PropsWithChildren<Test>, "value" | "children">'. Property 'extra' does not exist on type 'IntrinsicAttributes & BoxOwnProps<FC<Test>> & Pick<PropsWithChildren<Test>, "value" | "children">'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions