Skip to main content

Prettify<T>

Prettify<T> = { [K in keyof T]: T[K] } & object

Flattens intersection types for better IDE display.

When you have A & B & C, the IDE often shows the raw intersection. Prettify<T> forces TypeScript to expand it into a single object type, making hover tooltips much more readable.


Type Parametersโ€‹

T: Tโ€‹

The type to prettify


Sinceโ€‹

2.0.0


Exampleโ€‹

type A = { a: string };
type B = { b: number };
type C = { c: boolean };

type Ugly = A & B & C;
// IDE shows: A & B & C

type Pretty = `Prettify<A & B & C>`;
// IDE shows: { a: string; b: number; c: boolean }