...

/

Type Argument Propagation

Type Argument Propagation

This lesson talks about an interesting language feature related to generic functions introduced in TypeScript 3.4.

Overview #

Let’s have a look at the following example. Imagine that you’re fetching a collection of objects from some backend service and you need to map this collection to an array of identifiers.

interface Person {
  id: string;
  name: string;
  birthYear: number;
}

function getIds(persons: Person[]) {
    return persons.map(person => person.id);
}

Next, you decide to generalize the getIds function so that it works on any ...

Access this course and 1400+ top-rated courses and projects.