github gvergnaud/ts-pattern v4.0.4

latest releases: v5.5.0, v5.4.0, v5.3.1...
2 years ago

Fixes:

  • When nesting P.array() and P.select(), the handler function used to receive undefined instead of an empty array when the input array was empty. Now it received an empty array as expected:
match([])
    .with(P.array({ name: P.select() }), (names) => names)  /* names has type `string[]` and value `[]` */
    // ...
    .exhaustive()
  • The types used to forbid using an empty array pattern ([]) when matching on a value of type unknown. This has been fixed.
const f = (x: unknown) => match(x).with([], () => "this is an empty array!").otherwise(() => "?")

Commits:

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.