Skip to main content
Home

Make tolerable a poor man's version of exhaustive pattern-matching, in TypeScript

This package works with Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.8.2)

exhaustive is a function to help statically check that you explicitly handle all possible values.

See its documentation for a longer explanation. TypeScript's never type is the novel thing that makes it work.

We could copy & paste the function definition into a "utils" file in each project, but why not define it centrally and reuse it? That's why it's been put on this module registry:

import exhaustive from "jsr:@duncan/exhaustive"

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@duncan/exhaustive

Import symbol

import * as exhaustive from "@duncan/exhaustive";
or

Import directly with a jsr specifier

import * as exhaustive from "jsr:@duncan/exhaustive";

Add Package

pnpm i jsr:@duncan/exhaustive
or (using pnpm 10.8 or older)
pnpm dlx jsr add @duncan/exhaustive

Import symbol

import * as exhaustive from "@duncan/exhaustive";

Add Package

yarn add jsr:@duncan/exhaustive
or (using Yarn 4.8 or older)
yarn dlx jsr add @duncan/exhaustive

Import symbol

import * as exhaustive from "@duncan/exhaustive";

Add Package

npx jsr add @duncan/exhaustive

Import symbol

import * as exhaustive from "@duncan/exhaustive";

Add Package

bunx jsr add @duncan/exhaustive

Import symbol

import * as exhaustive from "@duncan/exhaustive";