Skip to Content
Programming TypeScript
book

Programming TypeScript

by Boris Cherny
May 2019
Intermediate to advanced content levelIntermediate to advanced
322 pages
7h 6m
English
O'Reilly Media, Inc.
Book available
Content preview from Programming TypeScript

Appendix A. Type Operators

TypeScript supports a rich set of type operators for working with types. Use Table A-1 as a handy reference for when you want to learn more about an operator.

Table A-1. Type operators
Type operator Syntax Use it on Learn more

Type query

typeof, instanceof

Any type

“Refinement”, “Classes Declare Both Values and Types”

Keys

keyof

Object types

“The keyof operator”

Property lookup

O[K]

Object types

“The keying-in operator”

Mapped type

[K in O]

Object types

“Mapped Types”

Modifier addition

+

Object types

“Mapped Types”

Modifier subtraction

-

Object types

“Mapped Types”

Read-only modifier

readonly

Object types, array types, tuple types

“Objects”, “Classes and Inheritance”, “Read-only arrays and tuples”

Optional modifier

?

Object types, tuple types, function parameter types

“Objects”, “Tuples”, “Optional and Default Parameters”

Conditional type

?

Generic types, type aliases, function parameter types

“Conditional Types”

Nonnull assertion

!

Nullable types

“Nonnull Assertions”, “Definite Assignment Assertions”

Generic type parameter default

=

Generic types

“Generic Type Defaults”

Type assertion

as, <>

Any type

“Type Assertions”, “The const type”

Type guard

is

Function return types

“User-Defined Type Guards”

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn React with TypeScript - Second Edition

Learn React with TypeScript - Second Edition

Carl Rippon
Understanding TypeScript

Understanding TypeScript

Maximilian Schwarzmüller
Learning TypeScript

Learning TypeScript

Josh Goldberg

Publisher Resources

ISBN: 9781492037644Errata PageSupplemental Content