github gvergnaud/ts-pattern v5.1.0

latest release: v5.1.1
one month ago

New features

P.nonNullable wildcard

Add a new P.nonNullable pattern that will match any value except null or undefined.

import { match, P } from 'ts-pattern';

const input = null;

const output = match<number | null | undefined>(input)
  .with(P.nonNullable, () => 'it is a number!')
  .otherwise(() => 'it is either null or undefined!');

console.log(output);
// => 'it is either null or undefined!'

Closes #60 #154 #190 and will be a work-around for #143.

What's Changed

Full Changelog: v5.0.8...v5.1.0

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.