Prettify

Expand and flatten complex TypeScript intersection types for readability.

#types #typescript #utility-type
export type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
// Usage
type A = { name: string };
type B = { age: number };
type Ugly = A & B;
// hover shows: A & B
type Pretty = Prettify<A & B>;
// hover shows: { name: string; age: number }

Share this snippet

Comments