Elestia Open Source Ratings
6.0

ts-pattern

Reasonable, with limits. 5th of 9 typed errors and functional programming.

ts-pattern is a small, mature library for exhaustive, type-safe pattern matching in TypeScript, with no dependencies. It is an excellent complement to typed errors, but it does not provide Result or Either types itself. To handle errors as values you pair it with a Result library such as neverthrow, better-result or Effect.

Best for: TypeScript teams that model outcomes and errors as discriminated unions and want the compiler to check that every case is handled.

GitHubnpm

Scores

Overall6.0

How strongly do we recommend it for a new project today?

Claude Opus 5.5: 6.0, likely 5.0 to 7.5

It is a high-quality, well-maintained tool, but it does only part of this category's job. It makes handling error unions exhaustive, yet you still need a Result library to represent and chain failures. Pick it as a companion to neverthrow, better-result or plain discriminated unions, not as the category's main choice.

GPT-6.2 Sol: 5.9, likely 4.8 to 7.0

ts-pattern earns its place when a project already returns typed errors and needs exhaustive handling of nested variants. True Myth supplies Results and typed async Tasks, and Effect carries a typed error channel through workflows, so both cover more of the category’s core job. Recent fixes support adopting it as a matcher, while the sparse release cadence and slower relative download growth temper the recommendation.

Needed by many4.8

How many developers need a tool for this job?

Claude Opus 5.5: 5.0, likely 4.0 to 7.0

Pattern matching on discriminated unions is useful in many TypeScript codebases, not only for errors. For this category's job, though, it serves only the 'handle every case' half, and only for TypeScript users. That puts it at a moderate niche within the category.

  • github description: Describes itself as a pattern-matching library, not an error-handling library
  • unpkg.com/ts-pattern@5.6.2/README.md: TypeScript-only; requires TS 5 and strict mode

GPT-6.2 Sol: 4.5, likely 3.4 to 5.8

Exhaustive matching is useful in frontend and backend TypeScript when errors, states, or events have several variants. In this category, it mainly helps teams that already model failures as unions. The State of JavaScript survey shows interest in pattern matching, while demand for this specific error-handling approach is harder to measure.

Helps a lot5.8

How well does it do the job for those who need it?

Claude Opus 5.5: 6.0, likely 5.0 to 7.5

As a pattern matcher it is the best-known option, with excellent inference and exhaustiveness checks. For typed errors it lacks Result types, combinators and async error chaining, which neverthrow, better-result and Effect provide. Runtime speed is reasonable but behind compiled matchers.

GPT-6.2 Sol: 5.6, likely 4.6 to 6.7

Version 5.9.2 narrows nested cases well and makes invalid-pattern diagnostics easier to read. The documented `.exhaustive()` call gives developers and coding agents a compiler check for omitted branches. Modeling errors, converting exceptions, and composing typed async failures require application code or another library. Type-checking cost grows with complex patterns, and runtime overhead depends on the workload.

Holds up over time6.6

Will it still be a good choice in two years?

Claude Opus 5.5: 6.5, likely 5.0 to 8.0

The project is active: it had a push the day before collection, 58 commits in the last year and releases in October 2026. It rests mostly on one maintainer, and 33 pull requests are open. The v5 API has been stable for years, and breaking changes are rare and limited to type checks.

  • github commitsLastYear: 58 commits; 2 releases last year
  • github openPullRequests: 33 open versus 104 merged
  • scorecard Maintained: Score of 10
  • github.com/gvergnaud/ts-pattern/releases: Steady minor releases on v5 with no major version bump

GPT-6.2 Sol: 6.7, likely 5.4 to 7.9

There were 58 commits in the past year, and the October patches improved compiler performance and diagnostics. Both patches landed in October 2026 after nearly a year between releases, and some inference reports have stayed open for months. Outside contributors landed fixes, while both recent releases came from the same maintainer.

Used widely5.9

How many use it, and is that growing?

Claude Opus 5.5: 7.0, likely 6.0 to 8.0

It has about 39M downloads per 4 weeks, 15k stars and 3.4k dependent repositories, which is broad direct use. Downloads grew 3.2x in a year, below the 4.1 median, so its share is slipping slightly. Part of the volume comes from transitive installs.

  • npm downloadsLast4Weeks: 39.1M, up from 12.2M a year before (ratio 3.2, below the median of 4.1)
  • dependents: 3,442 repos and 334 packages; fewer than fp-ts and True Myth, more than neverthrow
  • github stars: 15.2k stars, second in the category after Effect

GPT-6.2 Sol: 4.7, likely 3.4 to 6.1

Four-week npm downloads rose from 12.2 million to 39.1 million, a 3.22× increase below the catalog’s 4.1× median and neverthrow’s 4.90×. The indexed repository count trails True Myth and exceeds neverthrow’s, while 15 Bluesky posts show attention comparable to True Myth. Automated installs and downstream tooling inflate downloads, and the indexed dependents cover only part of GitHub.

Vouched for6.3

Who stands behind it being good?

Claude Opus 5.5: 6.0, likely 4.5 to 7.5

Many projects depend on it, and other libraries such as ArkType and schematch use it as the reference to compare against. Developers on Bluesky praise it. There is no survey data and no independent production write-up about using it for error handling.

GPT-6.2 Sol: 6.5, likely 5.2 to 7.8

Documenso’s signing package and ESLint React’s Web API plugin both depend on it. Users report that it makes nested result handling easier to read, and independent benchmarks show runtime trade-offs. The clearest endorsements are for pattern matching and cover a narrower use than typed error handling across an application.

Safe7.7

How safe is it to depend on?

Claude Opus 5.5: 8.0, likely 7.0 to 9.0

It has zero dependencies, no advisories ever and an MIT licence. The OpenSSF Scorecard is weak at 4.1: there is no branch protection, no security policy and little code review. Publishing rests on a single maintainer.

  • npm dependencies: 0 dependencies
  • advisories: No advisories recorded
  • scorecard score: 4.1 overall; Branch-Protection 0, Security-Policy 0, Code-Review 1

GPT-6.2 Sol: 7.3, likely 6.0 to 8.6

The MIT package has zero runtime dependencies and zero OSV advisories in the snapshot. The OpenSSF score is 4.1, with weak code review and zero scores for branch protection, security policy, and fuzzing. GitHub verifies the latest tag, and the package defines a test-and-build step before `npm publish`. Registry provenance and the number of authorized npm publishers remain unverified.

Good

  • `.exhaustive()` gives compile-time errors when a union case, such as a new error variant, is left unhandled.
  • It has zero dependencies, a tiny bundle and MIT licence, so it adds almost no supply-chain risk.
  • Type inference narrows matched values deeply, including nested objects, P.union, P.select and the new P.record patterns.
  • It has been stable on v5 for years, and recent releases mostly add features and speed up type checking.

Bad

  • It has no Result or Either type and no helpers to chain async errors, so it covers only half of the category's job.
  • Runtime matching is slower than a plain switch or compiled matchers such as ArkType's match.
  • Large matches can slow the TypeScript compiler, and it requires TypeScript 5 or later in strict mode.
  • Releases depend mostly on one maintainer, and pull requests pile up (33 open against 104 merged).

The numbers

npm downloads, 4 weeks
39M ×3.2 in a year
GitHub stars
15k
Commits, 12 months
58
npm version
5.9.2 Oct 2026
Versions, 12 months
2
Advisories, 24 months
0 of 0 ever
OpenSSF Scorecard
4.1 out of 10, Oct 2026
Licence
MIT

Read on 21 November 2026 from GitHub (gvergnaud/ts-pattern), npm (ts-pattern), OSV and the OpenSSF Scorecard.

Typed errors and functional programming

  1. 7.9Effect
  2. 7.1better-result
  3. 6.9True Myth
  4. 6.6byethrow
  5. 6.0ts-pattern
  6. 5.9neverthrow
  7. 5.3Boxed
  8. 5.2Purify
  9. 3.7fp-ts
Compare all 9 on six scores