Syntax

TypeScript Typed Arrow Function Syntax

In TypeScript, typed arrow function: types an arrow function — const add = (a: number, b: number): number => a + b;

Quick Answer

Syntax
const add = (a: number, b: number): number => a + b;
TypeScriptSyntax

Typed Arrow Function

Code example
const add = (a: number, b: number): number => a + b;

Types an arrow function.

Learn More

How to typed arrow function in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Typed Arrow Function Syntax

Use const add = (a: number, b: number): number => a + b;.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for typed arrow function?

Use this pattern: const add = (a: number, b: number): number => a + b;

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify