【问题标题】:Get type of value of mapped type [duplicate]获取映射类型的值类型[重复]
【发布时间】:2021-11-26 16:08:25
【问题描述】:

如果有类似的类型

interface ParsedQs { [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[] }

如何获取上述类型的值?我想要以下

type ParsedQsValue = undefined | string | string[] | ParsedQs | ParsedQs[]

无需从ParsedQs 定义中显式复制类型。

【问题讨论】:

    标签: typescript mapped-types


    【解决方案1】:
    type ParsedQsValue = ParsedQs[string]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 2013-06-21
      • 2015-11-20
      • 2011-09-15
      • 1970-01-01
      • 2017-08-08
      • 2019-07-19
      相关资源
      最近更新 更多