【问题标题】:Declare two types in interface Attributes在接口属性中声明两种类型
【发布时间】:2021-06-07 11:37:43
【问题描述】:

我需要声明这两个语句:

declare module "react" {
  interface Attributes {
    sx?: ThemeUIStyleObject;
  }
}

declare module "react" {
  interface Attributes {
    sx?: SxStyleProp;
  }
}

因为如果没有,sx 属性中会出现主题 UI 错误。

我试过了:

declare module "react" {
  interface Attributes {
    sx?: ThemeUIStyleObject | SxStyleProp;
  }
}

但仅适用于第一个对象(ThemeUIStyleObject)

【问题讨论】:

    标签: reactjs typescript next.js typescript-typings theme-ui


    【解决方案1】:

    尝试&加入这两种类型。

    sx?: ThemeUIStyleObject & SxStyleProp;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      • 2015-12-29
      相关资源
      最近更新 更多