Skip to main content
Hi there, I am Johnny

TypeScript type prettier

September 2024

TypeScript helper from Matt Pocock to reveal type details.

type ThemeMode = {
  mode: "light" | "dark";
};

type ThemeColor = {
  color: string;
};

type Theme = ThemeMode & ThemeColor;

For Theme type above, hover over it in VS Code, it does not actually drill into the actual type details. VS code no types

With the following helper

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

VS Code shows type details.
VS code with types