Skip to Content
Effective TypeScript, 2nd Edition
book

Effective TypeScript, 2nd Edition

by Dan Vanderkam
April 2024
Beginner to intermediate
404 pages
10h 6m
English
O'Reilly Media, Inc.
Content preview from Effective TypeScript, 2nd Edition

Chapter 2. TypeScript’s Type System

TypeScript can generate JavaScript (Item 3), but the type system is the main event. This is why you’re using the language!

This chapter walks you through the nuts and bolts of TypeScript’s type system: how to think about it, how to use it, choices you’ll need to make, and features you should avoid. TypeScript’s type system is surprisingly powerful and able to express things you might not expect a type system to be able to. The items in this chapter will give you a solid foundation to build upon as you write TypeScript and read the rest of this book.

Item 6: Use Your Editor to Interrogate and Explore the Type System

When you install TypeScript, you get two executables:

  • tsc, the TypeScript compiler

  • tsserver, the TypeScript standalone server

You’re much more likely to run the TypeScript compiler directly, but the server is every bit as important because it provides language services. These include autocomplete, inspection, navigation, and refactoring. You typically use these services through your editor. If yours isn’t configured to provide them, then you’re missing out! Services like autocomplete are one of the things that make TypeScript such a joy to use. But beyond convenience, your editor is the best place to build and test your knowledge of the type system. This will help you build an intuition for when TypeScript is able to infer types, which is key to writing compact, idiomatic code (see Item 18).

The details will vary from editor ...

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

Programming TypeScript

Programming TypeScript

Boris Cherny

Publisher Resources

ISBN: 9781098155056Errata PageSupplemental Content