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
- feat: Add P.nonNullable patterns by @gvergnaud in #229
Full Changelog: v5.0.8...v5.1.0