MUI5 custom typography typescript guide incorrect?

Viewed 236

I'm trying to setup custom typography variants in MUI5 by following this guide https://mui.com/customization/typography/#adding-amp-disabling-variants. When I add the type definitions in step 2

declare module '@mui/material/styles' {
  interface TypographyVariants {
    poster: React.CSSProperties;
  }

  // allow configuration using `createTheme`
  interface TypographyVariantsOptions {
    poster?: React.CSSProperties;
  }
}

// Update the Typography's variant prop options
declare module '@mui/material/Typography' {
  interface TypographyPropsVariantOverrides {
    poster: true;
    h3: false;
  }
}

into a file called typography.d.ts and with the examples swapped out for what I'm actually using, it seems to overwrite the entire module and I start seeing errors like

JSX element type 'Typography' does not have any construct or call signatures.

when trying to use the Typography component, or

Module '"@mui/material/styles"' has no exported member 'createTheme'.

when trying to create a theme.

Any thoughts?

1 Answers

The issue was that it was in a *.d.ts file; when I moved the typings into a normal *.ts file, all the warnings went away.

Related