Basic types

TypeScript supports a handful of built-in types; the following are examples of the most common ones:

const fullName: string = "John Doe";const age: number = 6;const isDone: boolean = false;const d: Date = new Date();const canBeAnything: any = 6;

As you can see, TypeScript supports basic primitive types such as string, number, boolean, and date.

Another thing to notice is the type any. The any type is a valid TypeScript type that indicates that the declaration can be of any given type and all operations on it should be allowed and considered safe.

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.