---
title: "ts-pattern"
description: "Exhaustive pattern matching for TypeScript with type narrowing, so unhandled union branches become compile errors instead of runtime bugs."
canonical: "https://vibing.inc/library/ts-pattern-vg-0958"
category: "Dev Utilities & Vibe-Coding Tooling"
subcategory: "Type-safe TypeScript"
license: "MIT"
author: "Gabriel Vergnaud (@gvergnaud)"
source: "https://github.com/gvergnaud/ts-pattern"
---

# ts-pattern
Exhaustive pattern matching for TypeScript with type narrowing, so unhandled union branches become compile errors instead of runtime bugs.
## Facts
- Source: https://github.com/gvergnaud/ts-pattern
- Category: Dev Utilities & Vibe-Coding Tooling / Type-safe TypeScript
- Author: Gabriel Vergnaud (@gvergnaud)
- Licence: MIT
- Tags: typescript, pattern-matching, type-safe, functional
## Why it's a gem
Replaces nested ternaries and switch soup with something the compiler can prove complete.
---
Listed in The Vibeary: https://vibing.inc/library/ts-pattern-vg-0958 · JSON: https://vibing.inc/api/public/library/gems/ts-pattern-vg-0958