github gvergnaud/ts-pattern v5.0.8

latest releases: v5.1.1, v5.1.0
3 months ago

The main thing

This release includes type narrowing improvement to isMatching when used in its curried form:

type Pizza = { type: 'pizza', topping: string };
type Sandwich = { type: 'sandwich', condiments: string[] }
type Food =  Pizza | Sandwich;

declare const food: Food

const isPizza = isMatching({ type: 'pizza' })

if (isPizza(food)) {
  x  // Used to  infer `food` as `Food`, no infers `Pizza`
}

This also improves type checking performance for complex patterns and fixes a small bug in the ES5 build of TS-Pattern.

What's Changed

  • perf: support exhaustive match on larger unions by @gvergnaud in #214
  • fix: make isMatching(p) infer the pattern as a const type parameter by @gvergnaud in #221
  • fix: Make sure regeneratorRuntime isn't included in the cjs build by @gvergnaud in #224

Full Changelog: v5.0.6...v5.0.8

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.