Basic and advanced type annotations
| Command | Description |
|---|---|
string | Text values |
number | Numeric values |
boolean | true / false |
any | Disable type checking (avoid) |
unknown | Safer any |
void | No return value |
null / undefined | Empty values |
never | Unreachable code |
| Command | Description |
|---|---|
string[] | Array of strings |
Array<number> | Array of numbers (generic) |
[string, number] | Tuple (fixed length & types) |
| Command | Description |
|---|---|
string | number | Union (either type) |
TypeA & TypeB | Intersection (merged types) |
type Status = "success" | "error" | Liteal union |
| Command | Description |
|---|---|
type User = { name: string } | Type alias |
interface User { name: string } | Interface |
enum Role { ADMIN, USER } | Enum |