MCPcopy
hub / github.com/gvergnaud/ts-pattern / f

Function f

tests/multiple-patterns.test.ts:217–222  ·  view source on GitHub ↗
(input: { t: 'a'; x: any } | { t: 'b' })

Source from the content-addressed store, hash-verified

215
216 it("when 2 returned values don't match, the error should be at the second returned value", () => {
217 const f = (input: { t: 'a'; x: any } | { t: 'b' }) =>
218 match<typeof input, string>(input)
219 .with({ t: 'a', x: 'hello' }, { t: 'a' }, (x) => 'ok')
220 // @ts-expect-error
221 .with({ t: 'b' }, (x) => 2)
222 .run();
223 });
224
225 it('issue #74: inference must work on every pattern in the list', () => {

Callers

nothing calls this directly

Calls 3

matchFunction · 0.90
runMethod · 0.80
withMethod · 0.80

Tested by

no test coverage detected