【发布时间】:2023-03-16 14:34:01
【问题描述】:
假设我可以访问这样定义的类型 Keys:
type Keys = ('AA' | 'BB' | 'CC')[]
- 如何创建一个新类型
Key,使用类型Keys,使这个新类型等于:
type Key = 'AA' | 'BB' | 'CC'
请注意,我不能从字面上指定允许的值(AA、BB 等),我只有 Keys 类型可供使用。
【问题讨论】:
标签: typescript types typing