Skip to Content
Installation

Last Updated: 3/6/2026


Installation

Via npm

npm install ts-pattern

Alternative Package Managers

You can also use your favorite package manager:

pnpm add ts-pattern # OR yarn add ts-pattern # OR bun add ts-pattern # OR npx jsr add @gabriel/ts-pattern

TypeScript Configuration

TS-Pattern works best with TypeScript 4.5 or later. Make sure your tsconfig.json has strict mode enabled for the best type inference:

{ "compilerOptions": { "strict": true } }