MUI5自定义排版打字指南不正确



我正试图按照本指南在MUI5中设置自定义排版变体https://mui.com/customization/typography/#adding-amp禁用变体。当我在步骤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;
}
}

转换成一个名为printing.d.ts的文件,并将示例替换为我实际使用的内容,它似乎覆盖了整个模块,我开始看到类似的错误

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

当尝试使用排版组件或时

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

尝试创建主题时。

有什么想法吗?

问题是它在*.d.ts文件中;当我把打字员转移到一个普通的*.ts文件中时,所有的警告都消失了。

最新更新