Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials TypeScript Function Types
TypeScript Intermediate FREE

Function Types

Lesson 1 of 17 Intermediate Interactive

TypeScript lets you define function parameter types and return types explicitly.

Syntax

TYPESCRIPT
function add(a: number, b: number): number {
    return a + b;
}

const multiply = (a: number, b: number): number => a * b;
Function Type Annotations
TYPESCRIPT
function add(a: number, b: number): number {
    return a + b;
}

const multiply = (a: number, b: number): number => a * b;

function greet(name: string): string {
    return `Hello, ${name}!`;
}

console.log(add(5, 3));
console.log(multiply(4, 2));
console.log(greet("SukhNexus"));

Practice

1
Exercise

Practice this concept.

Answer
Write the code as shown above.

Quick Quiz

1

What did you learn?

This covers the basics.

Interview Questions

It is a fundamental TypeScript feature.