0Pricing
TypeScript Academy · Lesson

Parameter and Return Type Annotations

Add types to function inputs and outputs.

Welcome

Typing function parameters and return values is one of the most important things you can do in TypeScript. It documents the contract and prevents bugs at call sites.

Parameter Types

Add a colon and type after each parameter name to annotate it.
function greet(name: string): string {
  return 'Hello, ' + name;
}

All lessons in this course

  1. Parameter and Return Type Annotations
  2. Optional and Default Parameters
  3. Rest Parameters and Spread with Types
  4. void, never, and Function Signatures
← Back to TypeScript Academy