0Pricing
TypeScript Academy · Lesson

Arrow functions & contextual typing

Use arrow functions confidently and see how contextual typing infers parameter/return types from usage.

Why arrows & context?

Arrow functions give concise syntax and lexical this. With contextual typing, TypeScript infers parameter and return types from usage (e.g., array methods), so you write less boilerplate while keeping safety.

Arrow basics

Annotate parameters/returns when it improves clarity. Arrows are compact and keep the surrounding this (unlike function declarations).

// Arrow syntax: parameters => expression/body
const greet = (name: string): string => {
  return `Hello, ${name}`;
};

console.log(greet("Ada"));

All lessons in this course

  1. If/else, switch, loops; truthiness & strict checks
  2. Functions: params, default/optional/rest; return types
  3. Arrow functions & contextual typing
← Back to TypeScript Academy