Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 575 Bytes

File metadata and controls

45 lines (32 loc) · 575 Bytes

typelab / utils / UnionLast

type UnionLast<T> = UnionToIntersection<T extends T ? Fn<[], T> : never> extends Fn<[], infer Result> ? Result : never;

Extracts the last type from a union type.

⚠️ Does not guarantee correct order.

Type Parameters

Type Parameter Description

T

The union type.

Returns

The last type in the union.

Example

// 'c'
type Last = UnionLast<'a' | 'b' | 'c'>;