Skip to main content

Using Generic Types

  • Chapter
  • First Online:
  • 2417 Accesses

Abstract

Generic types are placeholders for types that are resolved when a class or function is used, allowing type-safe code to be written that can deal with a range of different types, such as collection classes. This is a concept that is more easily demonstrated than explained, so I start this chapter with an example of the problem that generic types solve and then describe the basic ways that generic types are used. In Chapter 13, I describe the advanced generic type features that TypeScript provides. Table 12-1 summarizes the chapter.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Adam Freeman

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Freeman, A. (2019). Using Generic Types. In: Essential TypeScript. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4979-6_12

Download citation

Publish with us

Policies and ethics