TypeScript · Types and shapes

Type annotation

Declares the expected type of a value. Inference usually means you only annotate boundaries.

Syntax
const name: string = "Ada";

Example

Example
const name: string = "Ada";
const count: number = 3;
const active: boolean = true;

More in this group

any Array types enums Function type Interface Literal type never null and undefined

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course