Lesson 2.1

Generic functions and inference

A type parameter links an input type to an output type. Most of the skill is letting inference do the work rather than annotating call sites.

12mIntermediate18,683 students
Video thumbnail for Generic functions and inference

Sign in to watch this lesson

Browsing is free. Create an account to play videos and track your progress.

Overview

A type parameter links an input type to an output type. Most of the skill is letting inference do the work rather than annotating call sites.

What this lesson covers

  • Relate argument and return types with a type parameter
  • Let inference fill in type arguments at the call site
  • Recognise when a generic adds nothing over a union

This lesson sits in Generics, part of TypeScript for Application Developers. It assumes what came before it and leads directly into the next lesson in the module.

In this lesson you will:

  • Relate argument and return types with a type parameter
  • Let inference fill in type arguments at the call site
  • Recognise when a generic adds nothing over a union