【发布时间】:2021-05-01 17:44:46
【问题描述】:
我正在尝试提取泛型的类型,但无法访问它。所以我不能使用Extract。
import { Feather } from '@expo/vector-icons'
// The type is the following but isn't exported
const Feather: Icon<"crosshair" | "database" | "disc" | "zap" | "droplet" | "sun" | "wind" | "feather" | "link" | "search" | "image" | "menu" | "radio" | "key" | "code" | "map" | "video" | "circle" | ... 267 more ... | "zoom-out", "feather">
// ... how to get it icon list enum?
我正在尝试使用 "crosshair" | "database" | "disc" | "zap" ... 获取类型
我也试过这个answer
type TypeOfFeather = typeof Feather
type extractGeneric<T> = T extends TypeOfFeather <infer X> ? X : never
这显然不起作用,因为TypeOfFeather 不是通用的。我是 Typescript 的初学者,所以我真的不知道如何解决这个问题。
【问题讨论】:
标签: typescript types