Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

Mapped type modifiers

TypeScript 2.8 introduced a few operators that allow us to have a greater level of control over the definition of mapped types:

  • We can use the readonly modifier to flag a property as immutable.
  • We can use the ? operator to flag a property as optional.
  • We can use the + operator to apply a modifier, such as the readonly modifier, to a property in a type. We can also use the + operator with the ? operator.
  • We can use the - operator to apply a modifier, such as the readonly modifier to a property in a type. We can also use the + operator with the ? operator.

We will now examine a few examples. The code snippet declares a mapped type that can be used to transform a type, T, into a new type that contains all the properties ...

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

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content