Skip to content

Instantly share code, notes, and snippets.

@DarkAng3L
Forked from palashmon/Prettify.ts
Last active March 30, 2026 10:04
Show Gist options
  • Select an option

  • Save DarkAng3L/3761347b82a83eebccc34832d46cf17c to your computer and use it in GitHub Desktop.

Select an option

Save DarkAng3L/3761347b82a83eebccc34832d46cf17c to your computer and use it in GitHub Desktop.
A super useful type helper in TypeScript by Matt Pocock

Use case

Suppose you have a type that has many intersections:

export type SimpleShape = {
  color: string;
} & {
  size: number;
} & {
  shape: "circle" | "square";
};

When you hover over the type SimpleShape with many intersections, it can be difficult to see the resolved type. It would be helpful if there was a way to prettify the display of these types.

With Prettify we can using:

type Shape = Prettify<SimpleShape>;
//   ^? type Shape = {
//        color: string;
//        size: number;
//        shape: "circle" | "square";
//      }

Source: https://www.totaltypescript.com/concepts/the-prettify-helper

This is really helpful. Thank you, Matt!

/**
* A TypeScript type alias called `Prettify`.
* It takes a type as its argument and returns a new type that has the same properties as the original type,
* but the properties are not intersected. This means that the new type is easier to read and understand.
* See more: https://www.totaltypescript.com/concepts/the-prettify-helper
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment