Programming TypeScript has 13 chapters, but on their first day at a customer site, a Forward Deployed Engineer only needs three chapters and two appendices.
Quick Overview
- For an FDE, Chapter 11 on interoperating with JavaScript should be read first
- Appendices D and F break adding types to legacy code into safe, small steps
- Chapters 12 and 8 help debug Node services running on customers' own servers
Boris Cherny's Programming TypeScript has 13 chapters and 7 appendices. However, a Forward Deployed Engineer (FDE) who has just been given access to a customer's Node repository doesn't need to start from page one: Chapters 8, 11, and 12, plus Appendices D and F, are the parts most relevant to reading and fixing this kind of code.
Published by O'Reilly around May 2019, the book's subtitle is Making Your JavaScript Applications Scale. It targets intermediate JavaScript developers. It covers both frontend and backend, and also explains how to migrate existing JavaScript projects to TypeScript and run them in production.
The reason an FDE should read this book lies in the words "existing projects." At customer sites, there is rarely a chance to start from scratch. What you inherit is often a Node service written in plain JavaScript, a few outdated libraries, and a delivery deadline that doesn't allow a rewrite.
Start with Chapter 11, not Chapter 1
Chapter 11, "Interoperating with JavaScript," covers the incremental migration from JavaScript to TypeScript: starting with bringing in TSC and ending with enabling strict mode. This sequence matches exactly how an FDE works in someone else's repository.
Suppose the customer hands you a Node service of about 40 JavaScript files, and you need to modify the webhook handling flow, which involves 3 of them. Don't convert all 40 files.
First bring in TSC to check the existing code, then convert only the 3 files you must change. A small diff is something the customer's engineers can actually review; and the highest-risk places get accurate types first.
First thing to do when getting started: run TSC on the repository without changing a single line of code. The resulting list of errors is a map showing which parts of the code rely on implicit assumptions.
What about libraries without types?
The rest of Chapter 11 handles third-party JavaScript libraries in three cases. If the library ships its own type declarations, use them directly; if the declarations are on DefinitelyTyped, just install them; and the last case is libraries with no declarations at all — that's where the time goes.
For example, the customer has an internal npm package written years ago, exported via
module.exports
No one outside the company has ever written types for it. Appendix D, "Recipes for Writing Declaration Files for Third-Party JavaScript Modules," provides examples that target exactly the CommonJS and UMD export styles commonly used in old Node code.
What to do: on day one, sort all dependencies into these three groups. The third group determines how many hours you'll spend writing declaration files, and you should tell the customer that number before committing to a delivery date.
Tighten one option at a time
Appendix F, "TSC Compiler Flags for Safety," lists compiler options that make code safer. Applied to a customer's codebase, its value is that you can tighten them gradually instead of turning on strict mode all at once and getting hundreds of errors.
Suppose enabling just one option produces 120 errors. A pull request touching 120 places is hard for the customer's reviewers to approve readily. Enable one option at a time, one PR per option, with each PR handling one group of similar errors — then the customer's team can understand what you're doing and continue after you leave.
When errors show up on the customer's server
Chapter 12 has a dedicated section, "Running TypeScript on the Server," and also covers source maps, project references, and error monitoring. When a compiled service throws an exception in production, the stack trace points to the generated JavaScript files. Source maps can take you back to the exact line in TypeScript, so you don't have to guess when reading the customer's logs.
Chapter 8 fills in the rest of Node code: callbacks, Promises, async/await, event emitters, and type-safe multithreading with child processes. Customers' legacy services often mix callbacks and Promises, and adding types to these async boundaries is the fastest way to find out where errors are being swallowed.
What to do: before fixing the first bug, confirm whether the customer's build generates source maps and whether errors are reported to some monitoring tool.
Two common mistakes caused by getting the order wrong
The first mistake is enabling strict mode on day one. Chapter 11 puts strict last for a reason: enabling it on a JavaScript repository that has never had types turns a 3-file fix into a giant PR that nobody on the customer's side wants to review.
The second mistake is renaming the entire repository before sorting dependencies into three groups, turning it into
.ts
Only after converting all 40 files do you discover that the internal package has no type declarations at all. Every call site throws errors, and you have to stop halfway to write declaration files per Appendix D.
The book offers a way to avoid both mistakes: classify the libraries first, write declarations for the third group, then convert the files, and enable options one by one per Appendix F.
Who should read it, and in what order
This book suits people who write solid JavaScript but have never introduced TypeScript into an existing codebase. The recommended reading order: Chapter 11, Appendix D, Appendix F, Chapter 12, then Chapter 8.
For the earlier chapters on the type system, refer to them when you're unsure about a concept. The book was published in 2019, so details about the toolchain and compiler options should be verified against the current TypeScript documentation.
Reading alone isn't enough. Boris Cherny maintains an official GitHub repository
bcherny/programming-typescript-answers
with answers to the exercises, which you can check against after doing them yourself. An even better exercise is to incrementally migrate an open-source Node repository following the sequence in Chapter 11.
From a career perspective, this skill is easy to demonstrate. Writing on your resume "incrementally migrated a Node service from JavaScript to TypeScript, enabled strict mode one PR at a time, and wrote type declarations for internal CommonJS modules" is far more convincing than "familiar with TypeScript."
Imagine a job posting for an FDE role that says: the candidate will write code directly in customers' existing systems, with a tech stack of Node and TypeScript. This means the employer needs someone who can safely modify legacy code, and that resume line above answers exactly that need. Put it at the top of your work experience, along with a link to a repository you migrated yourself.
Look at the table of contents through the eyes of an FDE: these three chapters and two appendices are written for people who have to fix someone else's code without breaking it.
Was this article helpful?
Thanks for your feedback!