npm ts-pattern 4.2.1
v4.2.1

latest releases: 5.3.1, 5.3.0, 5.2.0...
19 months ago

Bug fixes

This release fixes inference of P.array when the input is a readonly array (issue #148)

declare const input: readonly {
  readonly title: string;
  readonly content: string;
}[];

const output = match(input)
  .with(
    P.array({ title: P.string, content: P.string }),
    //      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //              Used to error, now works 
    (posts) => 'a list of posts!'
  )
  .otherwise(() => 'something else');

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.