Item 36: Use a Distinct Type for Special Values
Effective TypeScript Blog
by
1M ago
It's tempting to use as special values: an empty string might represent text that hasn't loaded yet, or could stand in for a missing number. In TypeScript, this is almost always a bad idea. Special values need to be handled specially, and giving them a distinct type, such as , allows TypeScript to enforce that you do so ..read more
Visit website
Flow Nodes: How Type Inference Is Implemented
Effective TypeScript Blog
by
2M ago
If a variable gets a type but no one looks at it, does it really get a type at all? This post looks at how type inference is implemented in the TypeScript compiler. It's of some interest to anyone who uses TypeScript and is curious how it works, but it will be most relevant to developers who want to contribute to TypeScript itself ..read more
Visit website
The Making of a TypeScript Feature: Inferring Type Predicates
Effective TypeScript Blog
by
2M ago
Over the past few months I became a TypeScript contributor and implemented a new feature, , that should be one of the headliners for TypeScript 5.5. This post tells the story of how that happened: why I wanted to contribute to TypeScript, the journey to implementing the feature and getting merged, and what I've learned along the way. This is not a short read, but it will give you a good sense of what it's like to become a TypeScript contributor and develop a new feature ..read more
Visit website
Now Available: Effective TypeScript, Second Edition
Effective TypeScript Blog
by
2M ago
Fully updated, thoroughly revised, now with 50% more book ..read more
Visit website
Don't Write Traditional Getter and Setter Methods in JavaScript and TypeScript
Effective TypeScript Blog
by
5M ago
Sun 31 December 2023 ) are common in Java and considered a best practice. But they're a code smell that's best avoided in JavaScript and TypeScript because the problem they solve in Java does not exist in JS/TS. This post looks at what that problem is and how you can solve it in TypeScript without imposing the boilerplate of getters and setters ..read more
Visit website
Effective TypeScript Talk at Etsy (Dec 2020)
Effective TypeScript Blog
by
5M ago
Back in 2020 I gave a whole series of talks at companies that were interested in the language and the book. The talk that I gave at Etsy in December of 2020 was one of the most fun. It was recorded and is now available to watch. It's about an hour ..read more
Visit website
The Hidden Side of Type Predicates
Effective TypeScript Blog
by
5M ago
Type guards are a powerful tool for improving TypeScript's built-in control flow analysis. This post looks at when it's appropriate to use a type predicate, and in particular what it means when a type predicate returns ..read more
Visit website
Know How to Iterate Over Objects
Effective TypeScript Blog
by
7M ago
Use Source Maps to Debug TypeScript ..read more
Visit website
Avoid Cluttering Your Code with Inferable Types
Effective TypeScript Blog
by
7M ago
Use Functional Constructs and Libraries to Help Types Flow Functions Instead of Callbacks for Asynchronous Code ..read more
Visit website
Using infer to unpack nested types
Effective TypeScript Blog
by
8M ago
Wed 29 November 2023 keyword can infer quite a bit more than you might expect. It's extremely effective at extracting types from the sort of nested structures that you might get from codegen or an API specification ..read more
Visit website

Follow Effective TypeScript Blog on FeedSpot

Continue with Google
Continue with Apple
OR