Skip to content

v5.9.2

Latest

Choose a tag to compare

@gvergnaud gvergnaud released this 14 Oct 08:48
v5.9.2
f11be73

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