typeof in Types
typeof in a type position copies the type of a value. ReturnType gets a function result type.
Example
const cfg = { a: 1, b: "x" };
type Cfg = typeof cfg;
function f() { return 5; }
type R = ReturnType<typeof f>;
const r: R = 3;
console.log(r);Result
3
Exercise
Type of a value.
type T = value
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.