On this page
  1. typeof
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

typeof

Prev: `keyof` | Up: builtins | Next: `satisfies`
Rel: builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — typeof
Tags: #public #web #typescript #builtins #tier/core


Syntax & Overview

type Config = typeof DEFAULT_CONFIG;

In type position, extracts the static TypeScript type of a runtime value or function without duplicating type definitions.

Notes & Pitfalls

Example

const defaultSettings = { theme: "dark", fontSize: 14 };
type Settings = typeof defaultSettings; // { theme: string; fontSize: number }

const custom: Settings = { theme: "light", fontSize: 16 };

Linked from

Related notes