github gvergnaud/ts-pattern v4.2.1

latest releases: v5.3.1, v5.2.0, v5.1.2...
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.