gvergnaud/ts-pattern

🎨 The exhaustive Pattern Matching library for TypeScript, with smart type inference.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 11 minutes ago
Added to GitGenius on September 3rd, 2026
Created on May 24th, 2020
Open Issues & Pull Requests: 75 (+0)
GitHub issues: Enabled
Number of forks: 171
Total Stargazers: 15,146 (+0)
Total Subscribers: 31 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 2.1 days
Mean response time: 67.2 days
90th percentile: 183.9 days
Tracked items: 35

How this project is maintained

100% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. Three people close 96% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 30
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 638 days
Stale 30+ days: 30
Stale 90+ days: 29

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • enhancement (18)
  • bug (1)
  • workaround provided (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

ts-pattern is a pattern matching library for TypeScript that enables exhaustive, type-safe branching logic with smart type inference.

The library solves the problem of writing complex conditional logic by providing a functional programming approach to branching. Instead of nested if/else or switch statements, developers write pattern expressions that match against data structures. The tool performs exhaustiveness checking to ensure all possible cases are handled, catching logic errors at compile time. It supports matching on nested objects, arrays, tuples, sets, maps, and primitive types, with an expressive API that includes wildcards, predicates, unions, intersections, and exclusion patterns.

Developers should choose this tool when working with complex data structures where traditional conditionals become unwieldy or error-prone. It suits projects where type safety and code clarity are priorities, particularly those handling discriminated unions, nested data validation, or state machines. The library is lightweight, adding only a small bundle footprint to projects.

The project maintains active engagement with its community through regular issue responses and pull request reviews. Development follows a structured approach with clear documentation and examples. The maintainers prioritize type safety and inference quality, regularly refining how the library infers types from patterns. The codebase receives consistent updates addressing edge cases and expanding pattern matching capabilities.