question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Typography] typescript error Property 'component' does not exist

See original GitHub issue

The Typography types file doesn’t have a description for the ‘component’ prop which causes a type error.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When createing a typography component like so:

<Typography variant='h5' component='h6'>{title}</Typography>

causes typescript error:

Property ‘component’ does not exist on type 'IntrinsicAttributes & Pick…

I believe I am using Typography in a way that’s consistent with the documentation: https://v4-8-3.material-ui.com/api/typography/

Expected Behavior 🤔

As the ‘component’ prop is both in the JS code and the documentation, the typescript error should not be thrown.

It seems to me that it it’s caused but the ‘component’ prop not being described in this file (4.8.1):

https://github.com/mui-org/material-ui/blob/v4.8.1/packages/material-ui/src/Typography/Typography.d.ts

However, one version earlier, it is present and correct (4.8.0): https://github.com/mui-org/material-ui/blob/v4.8.0/packages/material-ui/src/Typography/Typography.d.ts

All subsequent versions also have this property removed.

Steps to Reproduce 🕹

Steps:

  1. Install Material-ui/core at 4.8.1 or above
  2. Create a Typography component
  3. Add the ‘component’ prop.
  4. Run any kind of typescript compiler.

Your Environment 🌎

Tech Version
Material-UI v4.8.3
React v16.12.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
oliviertassinaricommented, Aug 13, 2021

@DanMMX See the docs https://next.material-ui.com/guides/typescript/#usage-of-component-prop:

import React from "react";
import { Typography, TypographyProps } from "@material-ui/core";

export default function App<C extends React.ElementType>(
  props: TypographyProps<C, { component?: C }> & {
    isValid: boolean;
  }
) {
  return (
    <Typography variant="body2" {...props}>
      Test
    </Typography>
  );
}
2reactions
GustavoContreiras-Feegowcommented, Jan 14, 2022

How to solve?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Link] typescript error Property 'component' does not exist on ...
This is a very misleading error from TypeScript, as the issue is the badProp property, not the component property, but the error message ......
Read more >
Property 'component' does not exist on type 'IntrinsicAttributes
I have the following component, that does not compile: export default function MobileNav({routes, currentRouteIndex, ...
Read more >
property 'component' does not exist on type 'intrinsicattributes
As the 'component' prop is both in the JS code and the documentation, the typescript error should not be thrown. It seems to...
Read more >
Troubleshooting - Material UI - MUI
[Types] Property "palette", "spacing" does not exist on type 'DefaultTheme' ... This error arises because makeStyles is now exported from the @mui/styles package, ......
Read more >
Property 'registerRenderer' does not exist on type 'Renderers ...
But typescript in angular 5 complains with error: Property 'registerRenderer' does not exist on type 'Renderers'. Although in my angular component ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found