npm ts-pattern 5.9.2
v5.9.2

3 hours ago

Readable type errors

Type errors on invalid patterns now name the pattern type Pattern<...> instead of leaking internal types like KnownPatternInternal<string[], never, string[], never>.

match(input).with({ type: 'alpha', id: { value: 1, items: 'gamma' } }, () => 1)
// 5.9.1: Type 'string' is not assignable to type 'KnownPatternInternal<string[], never, string[], never> | undefined'.
// 5.9.2: Type 'string' is not assignable to type 'Pattern<string[]> | undefined'.

Invalid 2-argument .with() calls still report "No overload matches this call" (TS2769), as in 5.9.1. Type checking also got a little faster: 3-4% fewer instantiations on the 5.9.1 benchmarks.

What's Changed

  • fix(types): name the pattern type Pattern<...> in type errors by @gvergnaud in #384

Full Changelog: v5.9.1...v5.9.2

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.