Chapter 9. The Standard Library and External Type Definitions
TypeScript’s lead architect, Anders Hejlsberg, once said that he envisions “TypeScript to be the Switzerland of JavaScript,” meaning that it doesn’t prefer or work toward compatibility with a single framework but rather tries to cater to all JavaScript frameworks and flavors. In the past, TypeScript worked on a decorator implementation to convince Google not to pursue the JavaScript dialect AtScript for Angular, which was TypeScript plus decorators. The TypeScript decorator implementation also serves as a template for a respective ECMAScript proposal on decorators. TypeScript also understands the JSX syntax extension, allowing frameworks like React or Preact to use TypeScript without limitations.
But even if TypeScript tries to cater to all JavaScript developers and makes a huge effort to integrate new and useful features for a plethora of frameworks, there are still things it can’t or won’t do. Maybe because a certain feature is too niche, or maybe because a decision would have huge implications for too many developers.
This is why TypeScript has been designed to be extensible by default. A lot of TypeScript’s features like namespaces, modules, and interfaces allow for declaration merging, which gives you the possibility to add type definitions to your liking.
In this chapter, we look at how TypeScript deals with standard JavaScript functionality like modules, arrays, and objects. We will see some of their limitations, ...
Get TypeScript Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.