npm ts-pattern 4.0.4
v4.0.4

latest releases: 5.3.1, 5.3.0, 5.2.0...
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.