effective-typescript

by danvk

Effective TypeScript: 62 Specific Ways to Improve Your TypeScript

286 Stars 20 Forks Last release: Not found Other 17 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Effective TypeScript

This is the code sample repo for Effective TypeScript: 62 Specific Ways to Improve Your TypeScript. The book is available through:

and others.

You can get the latest updates on the book at https://effectivetypescript.com.

Code Samples

Below you'll find a complete table of contents with links to standalone code samples for each item. All code samples should produce the expected errors (and no others) and expected types.

Unless otherwise noted in a comment at the top of the code sample, the samples are run with TypeScript's

strict
setting. These were produced and checked using literate-ts and TypeScript 3.7.0-beta. You may want to copy/paste them into the TypeScript playground.
  • Chapter 1: Getting to Know TypeScript

  • Chapter 2: TypeScript’s Type System

    • :memo: Item 6: Use Your Editor to Interrogate and Explore the Type System
    • :memo: Item 7: Think of Types as Sets of Values
    • :memo: Item 8: Know How to Tell Whether a Symbol Is in the Type Space or Value Space
    • :memo: Item 9: Prefer Type Declarations to Type Assertions
    • :memo: Item 10: Avoid Object Wrapper Types (String, Number, Boolean, Symbol, BigInt)
    • :memo: Item 11: Recognize the Limits of Excess Property Checking
    • :memo: Item 12: Apply Types to Entire Function Expressions When Possible
    • :memo: Item 13: Know the Differences Between type and interface
    • :memo: Item 14: Use Type Operations and Generics to Avoid Repeating Yourself
    • :memo: Item 15: Use Index Signatures for Dynamic Data
    • :memo: Item 16: Prefer Arrays, Tuples, and ArrayLike to number Index Signatures
    • :memo: Item 17: Use readonly to Avoid Errors Associated with Mutation
    • :memo: Item 18: Use Mapped Types to Keep Values in Sync
  • Chapter 3: Type Inference

  • Chapter 4: Type Design

  • Chapter 5: Working with any

  • Chapter 6: Types Declarations and @types

    • :memo: Item 45: Put TypeScript and @types in devDependencies
    • :memo: Item 46: Understand the Three Versions Involved in Type Declarations
    • :memo: Item 47: Export All Types That Appear in Public APIs
    • :memo: Item 48: Use TSDoc for API Comments
    • :memo: Item 49: Provide a Type for this in Callbacks
    • :memo: Item 50: Prefer Conditional Types to Overloaded Declarations
    • :memo: Item 51: Mirror Types to Sever Dependencies
    • :memo: Item 52: Be Aware of the Pitfalls of Testing Types
  • Chapter 7: Writing and Running Your Code

  • Chapter 8. Migrating to TypeScript

    • :memo: Item 58: Write Modern JavaScript
    • :memo: Item 59: Use @ts-check and JSDoc to Experiment with TypeScript
    • :memo: Item 60: Use allowJs to Mix TypeScript and JavaScript
    • :memo: Item 61: Convert Module by Module Up Your Dependency Graph
    • :memo: Item 62: Don’t Consider Migration Complete Until You Enable noImplicitAny

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.