On this page
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
- In type position, captures the TypeScript type of a runtime value: Keeps a single source of truth instead of duplicating an interface alongside a default object.
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
- tuts/typescript/builtins/keyof Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/satisfies Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins Linked here; links to this page; shared tags: #builtins, #typescript, #web
- tuts/typescript/type_system/structural_typing_and_narrowing Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #builtins, #tier, #typescript, #web