Any programmer working with a dynamically typed language will tell you how hard it is to scale to more lines of code and more engineers. That's why Facebook, Google, and Microsoft invented gradual static type layers for their dynamically typed JavaScript and Python code. This practical book shows you how one such type layer, TypeScript, is unique among them: it makes programming fun with its powerful static type system.
If you're a programmer with intermediate JavaScript experience, author Boris Cherny will teach you how to master the TypeScript language. You'll understand how TypeScript can help you eliminate bugs in your code and enable you to scale your code across more engineers than you could before.
In this book, you'll:
Start with the basics: Learn about TypeScript's different types and type operators, including what they're for and how they're used
Explore advanced topics: Understand TypeScript's sophisticated type system,...
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Programming TypeScript — Reading Guide
## 【One-Line Pitch】
A practical, example-driven guide to mastering TypeScript's powerful static type system, written for intermediate JavaScript developers who want to eliminate bugs, document code better, and scale applications across more engineers and users.
## 【Book Arc】
- **Opening (~0%–9%)**: Introduces the motivation for TypeScript—how dynamically typed JavaScript struggles to scale—and outlines the book's dual aims of theory and practice, with early chapters focused on compiler fundamentals and later ones on real-world application.
- **Early (~9%–24%)**: Covers the basics of compilers, typecheckers, and types, establishing why type safety matters and how TypeScript differs from JavaScript's "make the best of it" approach to invalid operations.
- **Early (~24%–33%)**: Explores the type system's core philosophy—gradual typing, static type binding, and compile-time error checking—with concrete examples showing how TypeScript catches mistakes that JavaScript silently ignores.
- **Middle (~33%–42%)**: Delves into the TypeScript compiler pipeline (parse → AST → typecheck → emit JavaScript), explains type inference, and compares JavaScript's dynamic, weakly typed system against TypeScript's static, gradually typed approach.
- **Middle (~42%–52%)**: Covers practical setup—installing TSC and TSLint, configuring tsconfig.json, and choosing an editor—while emphasizing that TypeScript converts most runtime errors into compile-time errors surfaced in your editor as you type.
## 【Key Takeaways】
- **Type safety prevents invalid operations** (Early): TypeScript catches errors like multiplying a number by a list or calling methods that don't exist—mistakes JavaScript silently "fixes" with confusing results like `"3"` or `NaN`.
- **Compile-time errors beat runtime surprises** (Early): TypeScript surfaces errors in your text editor as you type, eliminating the disconnect between making a mistake and discovering it later through tests or user reports.
- **Gradual typing enables migration** (Middle): TypeScript works best with 100% type coverage but can compile untyped programs, making it ideal for incrementally migrating legacy JavaScript codebases.
- **Type inference reduces boilerplate** (Middle): TypeScript infers types automatically when you omit annotations—`let a = 1` is typed as `number`—so you should annotate only when necessary and let inference do the heavy lifting.
- **Static vs. dynamic binding changes everything** (Middle): JavaScript binds types at runtime and converts types implicitly; TypeScript binds types statically and refuses implicit conversions, complaining immediately about invalid operations like `3 + [1]`.
- **The compiler pipeline is parse → typecheck → emit** (Middle): TypeScript parses source into an AST, typechecks it for safety, then emits JavaScript that runs in any standard runtime—browser, NodeJS, or otherwise.
- **Not all errors are catchable** (Middle): Stack overflows, broken network connections, and malformed user inputs still cause runtime exceptions; TypeScript converts most type-related runtime errors to compile-time errors, not all errors.
## 【Reading Tips】
- **Skim the front matter** (~0%–9%): The preface and introduction are mostly motivational and organizational—skip ahead if you're already convinced TypeScript is worth learning.
- **Deep-read the type system comparisons** (~24%–42%): The JavaScript-vs-TypeScript table and the `3 + [1]` examples are the clearest explanations of why TypeScript matters—study these carefully to build your mental model.
- **Follow along with the setup chapter** (~42%–52%): Install TSC, TSLint, and create your tsconfig.json as you read—this is where theory becomes practice, and hands-on experience will cement the concepts.
- **Do the chapter exercises**: The author explicitly recommends attempting exercises yourself for deeper intuition; answers are available online at the book's GitHub repository.
- **Watch for the author's style choices**: Semicolons only when necessary, two-space indentation, and short variable names in snippets—these are personal preferences, not TypeScript requirements.
## 【Coverage Limits】
This guide covers the book's opening through the middle chapters (~0%–52%), focusing on fundamentals, type system philosophy, and setup. The excerpts do not cover advanced topics like sophisticated type system features, error handling, asynchronous programming, framework integration, or production deployment—these appear in later chapters not included in the sample.
##
Excerpt 1
al sales department: 800-998-9938 or corporate@oreilly.com . Development Editor: Angela Rufino Indexer: Margaret Troutman Acquisitions Editor: Jennifer Pollo...
ks, articles, conferences, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-dept...
ated bugs, this will actually change the way you write code. You will find yourself sketching out a program at the type level before you fill it in at the va...
icit about your intentions, TypeScript gets out of your way. This behavior makes sense: who in their right mind would try to add a number and an array, expec...
means. Fix the TypeError and see the red squiggly disappear. If you’re ambitious, try to write a piece of code that TypeScript is unable to infer the type fo...
xplicitly that your value is a specific boolean ( e and f ). In general, you will use the first or second way in your programs. Very rarely, you’ll use the f...
vors that style of programming over a nominally typed style. Structural typing A style of programming where you just care that an object has certain properti...
n the previous list. Table 3-1. Is the value a valid object? Value {} object Object {} Yes Yes Yes ['a'] Yes Yes Yes function () {} Yes Yes Yes new String('a...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Programming TypeScript (Boris Cherny)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Programming TypeScript (Boris Cherny)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment