Skip to content

Prettify

Flattens an intersection type into a single readable object type.

IDE tooltips for intersections like A & B & C often show the raw intersection instead of the resolved shape. Wrapping with Prettify forces TypeScript to expand and display the fully-resolved type.

Distributes over unions, so each member is prettified independently instead of collapsing to their shared keys.

Available since v3.0.0

import type { Prettify } from '@helpers4/type';
// or, from the all-in-one package (same code, one install):
import type { Prettify } from 'helpers4/type';
type Prettify<T> = T extends unknown ? { [K in keyof T]: T[K] } & {} : never
type A = { a: number };
type B = { b: string };
type Merged = A & B;        // shown as "A & B" in IDE
type Pretty = Prettify<Merged>; // shown as "{ a: number; b: string }"

View source on GitHub