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
- docs(patterns): fix incorrect P.map JSDoc example by @eunwoo-levi in #341
- fix(build): override rollup-plugin-typescript2 for picomatch compatibility by @hasanefeuygun in #361
- tests tsconfig: TS 7 compat by @gvergnaud in #373
- perf: reduce type instantiations for literal and discriminated-union matches by @gwkline and @gvergnaud in #372 (from #357)
New Contributors
- @gwkline made their first contribution in #357
- @eunwoo-levi made their first contribution in #341
- @hasanefeuygun made their first contribution in #361
Full Changelog: v5.9.0...v5.9.1