Infer a type from an existing value.
Section: Type Operators
Use `typeof` in types
typescript
typescript
const config = {
retries: 3,
cache: true,
};
type Config = typeof config;Explanation
`typeof` in a type position is useful when a runtime object already defines the shape.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Type Operators
Use indexed access types
Get a nested property type from another type.
Use template literal types
Compose string literal types from smaller pieces.
Generic identity function
Use a type parameter for reusable function typing.