TypeScript Essentials

Lesson 04 · 10 min

Functions

Type the input. TS often infers the output itself.

10 minLesson 4 of 10Practice includedAsk AI on any point

What matters in a function is its arguments and what it returns. You can skip the return type if it's obvious from return. Write it on public functions and when you want to lock in the contract: then an accidental return null becomes an error, not a surprise. The Functions section covers optional, rest, void and callbacks.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.