Skip to content

Instantly share code, notes, and snippets.

View Phryxia's full-sized avatar

Phryxia Phryxia

  • South Korea
View GitHub Profile
@karol-majewski
karol-majewski / homogeneous-array.ts
Created September 22, 2019 22:13
Homogeneous arrays in TypeScript (+ check if a type is a union)
type Singleton = string;
type Union = string | number;
type DistributedKeyOf<T> =
T extends any
? keyof T
: never;
type DistributedValueOf<T> = T[DistributedKeyOf<T>];