The book runs to 13 chapters, but three of them and two appendices are what an FDE needs on a client site from day one.
In brief
- For an FDE, chapter 11 on interoperating with JavaScript is the place to open the book first
- Appendices D and F turn adding types to legacy code into small, safe steps
- Chapters 12 and 8 help you debug a Node service running on the client's own servers
Boris Cherny’s Programming TypeScript has 13 chapters and 7 appendices. An FDE who has just been given access to a client’s Node repo does not need to start on page one, though: chapters 8, 11 and 12, plus Appendices D and F, are the parts closest to the job of reading and fixing that code.
The book is published by O’Reilly and came out around May 2019 under the subtitle Making Your JavaScript Applications Scale. It is aimed at intermediate JavaScript developers. It covers frontend and backend, along with how to migrate an existing JavaScript project to TypeScript and run it in production.
The words “existing project” are the reason an FDE should read it. On a client site you rarely get to start from scratch. What you inherit is usually a Node service written in plain JavaScript, a few outdated libraries and a deadline that rules out a rewrite.
Open the book at chapter 11, not chapter 1
Chapter 11, “Interoperating with JavaScript”, teaches migration from JavaScript to TypeScript one step at a time: it begins with adding TSC and ends with turning on strict mode. That order matches how an FDE should work in someone else’s repo.
Take a client who hands you a Node service of about 40 JavaScript files, and you need to change the webhook handling flow, which lives in three of them. Do not convert all 40 files.
Add TSC so it checks the existing code, then convert only the three files you have to touch. A small diff is one the client’s engineers can review, and you get correct types where the risk is highest.
What to do in the first session: run TSC on the repo without changing a line of code. The resulting list of errors is a map of where the code relies on unstated assumptions.
What to do with libraries that have no types
The rest of chapter 11 handles third-party JavaScript libraries in three cases. If a library ships its own type declarations, use them. If the declarations live on DefinitelyTyped, install them. The last case, where no declarations exist at all, is where the time goes.
Say the client has an internal npm package written years ago that exports via
module.exports
. Nobody outside the company has ever written types for it. Appendix D, “Recipes for Writing Declaration Files for Third-Party JavaScript Modules”, has recipes for exactly the CommonJS and UMD export styles that older Node code tends to use.
What to do: sort every dependency into those three groups on day one. The third group tells you how many hours you will spend writing declaration files, and that is the number to give the client before promising a delivery date.
Tighten types one flag at a time
Appendix F, “TSC Compiler Flags for Safety”, lists the compiler flags that make code safer. On a client’s codebase its value lies in letting you tighten gradually, instead of switching on strict mode in one go and getting hundreds of errors.
Suppose enabling a single flag surfaces 120 errors. A pull request that fixes 120 places will make the client’s reviewers reluctant to approve it. Turn on one flag at a time, one flag per PR, each PR covering a group of errors of the same kind, and the client’s team understands what you are doing and can carry on after you leave.
When errors blow up on the client’s server
Chapter 12 has a dedicated section, “Running TypeScript on the Server”, along with source maps, project references and error monitoring. When the compiled service throws in production, the stack trace points at the generated JavaScript file. Source maps take you back to the exact line of TypeScript, so you can read the client’s logs without guessing.
Chapter 8 fills in what is left for Node code: callbacks, Promises, async/await, event emitters and type-safe multithreading with child processes. A client’s legacy service often mixes callbacks with Promises, and typing those asynchronous boundaries is the fastest way to see where errors are being swallowed.
What to do: before fixing the first bug, check whether the client’s build produces source maps and whether errors are being sent to any monitoring tool.
Two common mistakes from working in the wrong order
The first mistake is turning on strict mode in the first session. Chapter 11 puts strict at the end for a reason: enabling it on a JavaScript repo that has never had types turns a three-file fix into a giant PR that nobody on the client side wants to review.
The second mistake is renaming the whole repo to
.ts
before sorting dependencies into the three groups. You finish converting 40 files and only then discover that the internal package has no type declarations at all. Every call site reports an error, and you have to stop halfway to write declaration files following Appendix D.
The book shows how to avoid both: classify libraries first, write declarations for the third group, and only then convert files and enable flags one by one following Appendix F.
Who should read it, and in what order
The book suits people who write solid JavaScript but have never brought TypeScript into an existing codebase. The suggested order: chapter 11, Appendix D, Appendix F, chapter 12, then chapter 8.
Open the early chapters on the type system when you hit a concept you are unsure of. The book came out in 2019, so check details on tooling and compiler flags against the current TypeScript documentation.
Reading is not enough. Boris Cherny maintains an official GitHub repo with answers to the exercises,
bcherny/programming-typescript-answers
, so you can work them yourself and compare. An even better exercise is to migrate an open-source Node repo gradually, following the sequence in chapter 11.
For your career, this skill is easy to demonstrate. A CV line such as “incrementally migrated a Node service from JavaScript to TypeScript, enabling strict mode PR by PR, and wrote type declarations for internal CommonJS modules” is far more convincing than “knows TypeScript”.
Consider an FDE job posting that says the candidate will write code directly in the client’s existing systems, on a Node and TypeScript stack. That signals an employer who needs someone able to change legacy code safely, and the CV line above answers that need; put it at the top of your experience section, with a link to the repo you migrated yourself.
Read with an FDE’s eye, the table of contents points to those three chapters and two appendices as the part written for people who must fix other people’s code without breaking it.
Was this article useful?
Thanks for the feedback!