【发布时间】:2023-03-17 09:25:01
【问题描述】:
给定:
interface ActionA {
type: 'AAAA';
stuff: string[];
}
interface ActionB {
type: 'BBBB';
otherStuff: string[];
}
有没有类似的东西:
type ActionTypes = ExtractToUnion<ActionA | ActionB, "type">;
构造一个类型:
type ActionTypes = 'AAAA' | 'BBBB';
【问题讨论】:
标签: javascript typescript types extract union