Problem Statement
What does typeof at the type level do?
Explanation
In type positions, `typeof` extracts a compile-time type from a value. In value positions, `typeof` returns runtime strings like "number". Use the type-level form to keep type definitions aligned with constants.
Code Solution
SolutionRead Only
const CONFIG = { host: 'localhost', port: 3000 } as const;
type Config = typeof CONFIG; // { readonly host: 'localhost'; readonly port: 3000 }
function connect(cfg: Config) { /* ... */ }