TypeScript — Command Reference
TypeScript adds type safety to JavaScript — errors are caught before running. Most used type structures, each with an explanation and working example.
6 categories · 18 commands
🖥️
Basics & Output
Output and the basic logic of TypeScript.
console.log()Adding types ( : )Type inference🏷️
Types
Union types, literal types, and special cases.
Union type ( | )Literal typeany / unknown📐
Interface & Type Alias
Defining object shapes: interface and type.
interfaceOptional area ( ? )type (alias)🧩
Function
Safe functions with parameter and return types.
Typed functionTyped arrow functionvoid (no return value)📋
Array & Object Types
Typed arrays, tuples, and record types.
Typed arr ( type[] )Tuple (tuple)Record<K, V>🚀
Next
Generics, enums, and type casting.
Generic ( <T> )enumas (type assertion)