TypeScript: Typing functions

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


A function can accept values as parameters, and return values after its execution.

So we must have 2 types: the type of the parameters values, and the type of the return value.

This is how a function accepts arguments of a specific type:

const multiply = (a: number, b: number) => {
  return a * b
}

Now try writing multipl( in your editor, you will see VS Code suggests you the types of the function as you type it:

This is really handy especially when using functions you didn’t write, maybe coming from a library you imported.

If you watch closely, TypeScript already inferred the return type is number.

In this case you don’t need to, but here is how functions can explicitly declare their return value:

const multiply = (a: number, b: number): number => {
  return a * b
}

Lessons in this unit:

0: Introduction
1: Your first TypeScript program
2: Types
3: ▶︎ Typing functions
4: The editor helps you with type errors
5: Running TypeScript code
6: Valid types
7: Type aliases and interfaces
8: Union types
9: Typing arrays with generics
10: The DX of editing TypeScript
11: There's more...
12: TypeScript declare a type that can be a string or array of strings
13: TypeScript, disable checks for `declared but its value is never read`
14: Object destructuring with types in TypeScript
15: TypeScript Tutorial
16: Zod: Type-Safe Schema Validation for TypeScript
17: How I fixed some trouble importing types in .d.ts files