npm ts-pattern 4.2.1
v4.2.1

latest releases: 5.5.0, 5.4.0, 5.3.1...
21 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.