| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-10-13 | 1.8 kB | |
| v5.9.1 source code.tar.gz | 2026-10-13 | 279.6 kB | |
| v5.9.1 source code.zip | 2026-10-13 | 319.5 kB | |
| Totals: 3 Items | 600.9 kB | 0 | |
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 https://github.com/gvergnaud/ts-pattern/pull/341
- fix(build): override rollup-plugin-typescript2 for picomatch compatibility by @hasanefeuygun in https://github.com/gvergnaud/ts-pattern/pull/361
- tests tsconfig: TS 7 compat by @gvergnaud in https://github.com/gvergnaud/ts-pattern/pull/373
- perf: reduce type instantiations for literal and discriminated-union matches by @gwkline and @gvergnaud in https://github.com/gvergnaud/ts-pattern/pull/372 (from [#357])
New Contributors
- @gwkline made their first contribution in https://github.com/gvergnaud/ts-pattern/pull/357
- @eunwoo-levi made their first contribution in https://github.com/gvergnaud/ts-pattern/pull/341
- @hasanefeuygun made their first contribution in https://github.com/gvergnaud/ts-pattern/pull/361
Full Changelog: https://github.com/gvergnaud/ts-pattern/compare/v5.9.0...v5.9.1