Home

TypeScript

TIP: Check this page code to see TypeScript features in action

Generics

Generics are a way to make components reusable across different types.

1

2

3

a

b

c

Union Types

Union types allow you to have multiple types for a single variable.

1

a

2

b

Readonly

Readonly arrays can't be modified.

10

20

30

Tuple

Tuples are fixed-length arrays that can have multiple types in them.

string

true

Named Tuple

John

35

Enum

Enums allow you to create a set of named constants.

#f00

#0f0

#00f

Enums can also be numbered, and the following values will be incremented

1

2

3

Type aliases and interfaces

Type aliases are a way to define custom types in TypeScript.

Hello Type Alias

Interfaces

Interfaces are generally used when defining objects instead of types.

John is 35 years old

Extended Interfaces

Interfaces can be extended to add more properties.

John is 35 years old and his email is john@email.com