繁体   English   中英

从另一个扩展接口 - MUI

[英]Extend interface from another - MUI

我有一个界面

interface ThemeBase {
  colors: {
    [key: string]: Color;
  };
  borderRadius: {
    base: string;
    mobile: string;
  };
  navbar: {
    'z-index': number;
  };
  typography: {
    rootBase: string;
    fontBase: string;
  };
}

我想用这个界面扩展 MUI 主题。 这个解决方案对我有用:

declare module '@material-ui/core/styles/createMuiTheme' {
  interface Theme extends ThemeBase {}
  // allow configuration using `createMuiTheme`
  interface ThemeOptions extends ThemeBase {}
}

但是我有一个来自 eslint 的错误

错误声明没有成员的接口等效于其超类型@typescript-eslint/no-empty-interface

如何在没有主题和主题选项的代码重复的情况下解决此问题

这是 IMO 完全可以将/* eslint-ignore @typescript-eslint/no-empty-interface */放在第一行的少数几个例子之一。 虽然我不会在常规代码中这样做,但模块扩充有点不同,在这里尝试找到解决方法是没有意义的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM