【问题标题】:How can I duplicate a TypeScript interface but change the property type in the duplication?如何复制 TypeScript 接口但更改复制中的属性类型?
【发布时间】:2022-06-16 17:24:34
【问题描述】:

我有以下接口,它们非常相似,但属性类型不同:

export interface ChannelOverlayStyles {
    bigChannelLogoWrapper: ViewStyle;
    bigPackshotChannelLogo: ViewStyle;
    channelLogo: ViewStyle;
    channelPackshotGradient: ViewStyle;
    smallChannelLogoWrapper: ViewStyle;
    portraitLogo: ViewStyle;
    landscapeLogo: ViewStyle;
}

 export interface ChannelOverlayStylesWeb {
    bigChannelLogoWrapper: ViewStyleWeb;
    bigPackshotChannelLogo: ViewStyleWeb;
    channelLogo: ViewStyleWeb;
    smallChannelLogoWrapper: ViewStyleWeb;
    portraitLogo: ViewStyleWeb;
    landscapeLogo: ViewStyleWeb;
 }

我可以通过创建一个复制第一个接口但自动替换属性类型的类型来避免重复这些吗?

【问题讨论】:

  • 您尝试了什么,为什么没有成功?

标签: typescript


猜你喜欢
  • 1970-01-01
  • 2017-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-11
  • 1970-01-01
相关资源
最近更新 更多