Syntax

TypeScript Typed Function Syntax

In TypeScript, typed function: types a function's parameters and return value — function add(a: number, b: number): number { return a + b; }

Quick Answer

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

Typed Function

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

Types a function's parameters and return value.

Learn More

How to typed 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 Function Syntax

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

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for typed function?

Use this pattern: function add(a: number, b: number): number { return 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