github gvergnaud/ts-pattern v5.9.1

6 hours ago

Faster type checking

Large .exhaustive() matches type-check much faster. Fast paths for primitive patterns and an early exit for object patterns cut type instantiations by about 70-80% on big literal unions and about 35% on discriminated unions. This is the work of @gwkline in #357, shipped through #372. Thank you Gavin!

  • literal union, 200 members: 788,205 → 240,909 instantiations (−69%)
  • literal union, 400 members: 2,470,005 → 447,609 (−82%)
  • discriminated union, 20 variants: 488,507 → 319,005 (−35%)

Error messages on invalid code

An invalid 2-argument .with() now reports "No overload matches this call" (TS2769). It is usually on the same spot as before. Two cases move it to the .with name: a pattern with 2+ invalid values (one error listing both), and a second argument that isn't a function. Valid code type-checks the same.

What's Changed

New Contributors

Full Changelog: v5.9.0...v5.9.1

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.