Built-ins: ReturnType, Parameters, InstanceType, etc.
Know and apply key built-in utility types: ReturnType, Parameters, InstanceType, ThisParameterType, OmitThisParameter, ConstructorParameters.
Built-ins: ReturnType, Parameters, InstanceType, etc. is a free TypeScript Academy lesson on CoddyKit. This is lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, and your progress syncs across the web and the CoddyKit app. The TypeScript Academy course includes 3 lessons in total.
Intro
Goal: Use built-in utility types efficiently. You'll map functions/constructors to their return, parameters, instance, and this types.
- ReturnType, Parameters
- InstanceType, ConstructorParameters
- ThisParameterType, OmitThisParameter
ReturnType & Parameters
ReturnType infers the return type, Parameters the parameter tuple; reduces fragility in refactors.
function greet(name: string) { return `Hi ${name}` }
// built-ins
type R = ReturnType<typeof greet> // string
type P = Parameters<typeof greet> // [name: string]Instance & Ctor params
InstanceType returns the instance returned by the constructor; ConstructorParameters returns the constructor arguments as a tuple.
class Box { constructor(public w: number, public h: number) {} }
type I = InstanceType<typeof Box> // Box
type C = ConstructorParameters<typeof Box> // [w: number, h: number]this utilities
ThisParameterType returns the function's this parameter, and OmitThisParameter returns a signature with it omitted.
function move(this: { x: number; y: number }, dx: number, dy: number) {
this.x += dx; this.y += dy
}
type ThisT = ThisParameterType<typeof move> // { x: number; y: number }
type MoveNoThis = OmitThisParameter<typeof move> // (dx: number, dy: number) => voidChaining built-ins
Chain built-in types: get method signature from class instance, resolve return type, extract Promise with infer if necessary.
class Http {
constructor(public base: string) {}
get(path: string) { return Promise.resolve(`${this.base}${path}`) }
}
type Client = InstanceType<typeof Http> // Http
type GetReturn = ReturnType<Client["get"]> // Promise<string>
type GetArgs = Parameters<Client["get"]> // [path: string]
type GetResolved = GetReturn extends Promise<infer U> ? U : GetReturn // stringTips
Tips: Try built-ins first; document APIs that use this; avoid any on the public surface.
// Tips
// - Prefer built-ins over custom re-implementations
// - Document when a type exposes this
// - Avoid any in public APIs; utilities lose precision
// - Keep function types nominal via object wrappers if neededBuilt-ins check
Quick check: Which built-in extracts the instance type produced by a constructor function?
Recap
Recap: ReturnType/Parameters for functions; InstanceType/ConstructorParameters for classes; ThisParameterType/OmitThisParameter for this-aware APIs.
Learn TypeScript with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 101
- Lessons
- 352
Frequently Asked Questions
Is the “Built-ins: ReturnType, Parameters, InstanceType, etc.” lesson free?
Yes — the full text of “Built-ins: ReturnType, Parameters, InstanceType, etc.” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO. The TypeScript Academy course includes 3 lessons in total.
What will I learn in “Built-ins: ReturnType, Parameters, InstanceType, etc.”?
Know and apply key built-in utility types: ReturnType, Parameters, InstanceType, ThisParameterType, OmitThisParameter, ConstructorParameters. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 3.
How long does the “Built-ins: ReturnType, Parameters, InstanceType, etc.” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- T extends U ? X : Y in practice
- infer for ReturnType-like utilities
- Built-ins: ReturnType, Parameters, InstanceType, etc.