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 9. Writing and Running Your Code

This chapter is a bit of a grab bag: it covers some issues that come up in writing code (not types) as well as issues you may run into when you run your code.

Item 72: Prefer ECMAScript Features to TypeScript Features

The relationship between TypeScript and JavaScript has changed over time. When Microsoft first started work on TypeScript in 2010, the prevailing attitude around JavaScript was that it was a problematic language that needed to be fixed. It was common for frameworks and source-to-source compilers to add missing features like classes, decorators, and a module system to JavaScript. TypeScript was no different. Early versions included home-grown versions of classes, enums, and modules.

Over time, TC39, the standards body that governs JavaScript, added many of these same features to the core JavaScript language. And the features they added were not compatible with the versions that existed in TypeScript. This left the TypeScript team in an awkward predicament: adopt the new features from the standard or maintain existing code?

TypeScript has largely chosen to do the former and eventually articulated its current governing principle: TC39 defines the runtime, while TypeScript innovates solely in the type space.

There are a few remaining features from before this decision. It’s important to recognize and understand these, because they don’t fit the pattern of the rest of the language. In general, I recommend avoiding them to keep ...

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