50 TypeScript F*ck Ups
50 TypeScript F*ck Ups
50 Subtle Mistakes to Screw Your Code and How to Avoid and Fix Them to Write Extraordinary Software for Web
About the Book
Insider knowledge on recognizing common bugs, errors, and pitfalls in the TypeScript code.
The best mistakes are the ones you avoid in the first place. 50 TypeScript F*ck Ups makes it easy to identify errors before you even make them! It’s packed with over a hundred anti-patterns, common slip-ups, and complex technical points that can trip up even the most experienced JavaScript or TypeScript developer.
In 50 TypeScript F*ck Ups (Mistakes) you’ll learn about:
- JavaScript and TypeScript for frontend and backend
- Resolving persistent, dangerous, or frustrating issues
- How to write safer code
- Increase code quality, reusability, and maintainability
- Industry best practices
Open up 50 TypeScript F*ck Ups and you’ll instantly find practical, reliable ways to improve your JavaScript and TypeScript code. Make your code safer, improve readability and reusability, and become the go-to JS and TypeScript guru on your team!
Table of Contents
- Welcome
- 1. Why TypeScript and Why This Book
- 1.1. Why TypeScript?
- 1.2. How does TypeScript work?
- 1.3. How this book is structured
- 1.4. How to use this book
- 1.5. For whom this book is intended
- 1.6. Why this book will help you
- 1.7. Summary
- 2. Basic TypeScript Mistakes
- 2.1. Using any Too Often
- 2.2. Ignoring Compiler Warnings
- 2.3. Not Using Strict Mode
- 2.4. Declaring Variables Incorrectly
- 2.5. Misusing Optional Chaining
- 2.6. Not Using Nullish Coalescing
- 2.7. Not Exporting/Importing Properly
- 2.8. Not Using or Misusing Type Assertions
- 2.9. Checking for Equality Improperly
- 2.10. Not Understanding Type Inference
- 2.11. Summary
- 3. Types, Aliases and Interfaces
- 3.1. Confusing Types Aliases and Interfaces
- 3.2. Misconceiving Type Widening
- 3.3. Ordering Type Properties Inconsistently
- 3.4. Extending Interfaces Unnecessarily
- 3.5. Missing on Opportunities to Use Type Aliases
- 3.6. Avoiding Type Guards
- 3.7. Overcomplicating Types
- 3.8. Overlooking readonly Modifier
- 3.9. Forgoing keyof Utility Type
- 3.10. Underutilizing Utility Types Extract and Partial When Working with Object Types
- 3.11. Summary
- 4. Functions and Methods
- 4.1. Omitting Return Types
- 4.2. Mishandling Types in Functions
- 4.3. Misusing Optional Function Parameters
- 4.4. Inadequate Use of Rest Parameters
- 4.5. Not Understanding this
- 4.7. Not Knowing About globalThis
- 4.8. Disregarding Function Signatures in Object Type
- 4.9. Incorrect Function Overloads
- 4.10. Misapplying Function Types
- 4.11. Ignoring Utility Types for Functions
- 4.12. Summary
- 5. Classes and Constructors
- 5.1. Understanding When to Implement Interfaces for Classes
- 5.2. Misusing Abstract Classes
- 5.3. Misuse of Static Members
- 5.4. Incorrectly Applying Access Modifiers
- 5.5. Not Initializing Class Properties
- 5.6. Overriding Methods Incorrectly
- 5.7. Inconsistent Getters and Setters
- 5.8. Not Knowing About Composition Over Class Inheritance
- 5.9. Mishandling Promises in Constructors
- 5.10. Not Leveraging Decorators in Classes
- 5.11. Summary
- 6. Advanced Parts and Bad Parts of TypeScript
- 6.1. Not Knowing Generic and Their Constraints
- 6.2. Overusing Generics in Functions
- 6.3. Failing to Use Generic Utility Types Pick and Partial
- 6.4. Not Understanding Conditional Types in Generics
- 6.5. Using Enums Instead of Union Types
- 6.6. Not replacing tuples with objects when possible
- 6.7. Not Knowing Various Type Narrowing Techniques
- 6.8. Using Use of ‘instanceof’ With Non-Classes
- 6.9. Failing to Use Discriminated Unions
- 6.10. Overlooking Async/Await Pitfalls
- 6.11. Summary
- 7. Outro
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them