Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore TypeScript CheatSheet

TypeScript CheatSheet

Published by 200labeducation, 2021-12-02 07:53:13

Description: TypeScript CheatSheet

Search

Read the Text Version

USAGE Install Run Run with a specific config

TRIPLE SLASH DIRECTIVES Reference built-in types Reference other types AMD

COMPILER COMMENTS Don’t check this file Check this file (JS) Ignore the next line

Expect an error on the next line O P E R A T O R S (TypeScript-specific and draft JavaScript) ?? (nullish coalescing operators)

?. (optional chaining operators) ! (null assertion operators) &&=

||= ??= BASIC TYPES Untyped String Number

True / false value Non-primitive value Uninitialized value Explicitly empty value Null or undefined Value that can (usually only used for never occur function returns) Value with an unknown type

OBJECT TYPES Object Object with arbitrary string properties (like a hashmap or dictionary)

LITERAL TYPES String Numeric ARRAYS AND TUPLES Array of strings

Array of functions that return strings Basic tuples Variadic tuples

Named tuples FUNCTIONS Function type Constructor

Function type with optional param Function type with rest param Function type with static property Default argument Arrow function

this typing Overloads UNION AND INTERSECTION TYPES Union Intersection

NAMED TYPES Interface Class

Enum Type alias

GENERICS Function using type parameters Interface with multiple types Constrained type parameter Default type parameter

Constrained and default type parameter Generic tuples INDEX, MAPPED, AND CONDITIONAL TYPES Index type query (keyof)

Mapped types Conditional types Conditional mapped types

UTILITY TYPES Partial Readonly Pick

Record Exclude Extract

NonNullable ReturnType InstanceType

TYPE GUARDS Type predicates typeof

instanceof in

ASSERTIONS Type Const (immutable value)

AMBIENT DECLARATIONS Global Module Wildcard module


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook