ts-pattern
gvergnaud/ts-pattern · Public GitHub repository
🎨 The exhaustive Pattern Matching library for TypeScript, with smart type inference.
Open the project to try its demo, view the repository, or save it to your collection. Repository and demo actions use RepoShelf’s sign-in flow.

About this project
Author-written excerpt from the project README.
The exhaustive Pattern Matching library for TypeScript with smart type inference.
Write better and safer conditions. Pattern matching lets you express complex conditions in a single, compact expression. Your code becomes shorter and more readable. Exhaustiveness checking ensures you haven’t forgotten any possible case.
Pattern Matching is a code-branching technique coming from functional programming languages that's more powerful and often less verbose than imperative alternatives (if/else/switch statements), especially for complex conditions.
- Pattern-match on any data structure: nested Objects, Arrays, Tuples, Sets, Maps and all primitive types.
- Typesafe, with helpful type inference.
- Exhaustiveness checking support, enforcing that you are matching every possible case with .exhaustive().
- Use patterns to validate the shape of your data with isMatching.
- Expressive API, with catch-all and type specific wildcards: P., P.string, P.number, etc.
Requirements and intended audience
The exhaustive Pattern Matching library for TypeScript with smart type inference.
Not recorded: account, external api key, paid service, self-hosting. Missing information does not mean there are no requirements.
Statements extracted from the author’s documentation · Checked 2026-11-02. Source: https://github.com/gvergnaud/ts-pattern/blob/main/README.md
Recorded maintenance information
Last recorded source update: 2026-11-20. Saved release: v5.9.2 · 2026-10-14. These dates do not guarantee ongoing maintenance.
- Technologies
- TypeScript
- Licence
- MIT. Generally permits modification and commercial use, subject to the licence’s notices and conditions.
- Demo check
- A public page loaded on 2026-11-23. This does not test every feature.
Browse related categories
More projects to explore
awesome-selfhosted
awesome-selfhosted/awesome-selfhosted
A list of Free Software network services and web applications which can be hosted on your own servers
awesome-go
avelino/awesome-go
A curated list of awesome Go frameworks, libraries and software
NextChat
ChatGPTNextWeb/NextChat
✨ Zero-config AI chat assistant. No API key needed — sign up and instantly chat with GPT-5, Claude 4, Gemini 2.5, DeepSeek & 100+ top models. Pay-as-you-go saves you more. Available on Web, iOS, macOS, Android, Linux, Windows.
vue-element-admin
PanJiaChen/vue-element-admin
A magical vue admin https://panjiachen.github.io/vue-element-admin