Skip to content

[system] <Box component={Paper} square> throws unasignable type #16843

@mayteio

Description

@mayteio

What it says on the tin - using typescript

  • [√] This is not a v0.x issue.
  • [√] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

Shouldn't complain when passing attributes component should accept

Current Behavior 😯

Does complain:

Type '{ children: Element; component: ComponentType<PaperProps>; square: true; className: string; }' is not assignable to type 'IntrinsicAttributes & BoxProps & { children?: ReactNode; }'.
  Property 'square' does not exist on type 'IntrinsicAttributes & BoxProps & { children?: ReactNode; }

Steps to Reproduce 🕹

https://codesandbox.io/s/kind-haslett-38ykt

Context 🔦

I want to leverage the awesome attributes Box gives me whilst using other components, for example;

<Box 
  component={Paper} 
  minHeight={320} // <Box /> prop
  square // <Paper /> prop
/>

From the typescript guide:

Not every component fully supports any component type you pass in. If you encounter a component that rejects its component props in TypeScript please open an issue. There is an ongoing effort to fix this by making component props generic.

Your Environment 🌎

Tech Version
Material-UI v5.0.0.alpha.13
React 1.6.8
Browser Chrome 75
TypeScript 3.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: BoxThe React component.scope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUItype: bugIt doesn't behave as expected.typescript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions