Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ts_matches/src/matches.ts>shape

Being able to pattern match in typescript
Go to Latest
function shape
Re-export
import { shape } from "https://deno.land/x/ts_matches@v5.2.0/src/matches.ts";

Type Parameters

A extends { }
Overwrites extends keyof A

Parameters

testShape: [key in keyof A]: Parser<unknown, A[key]>
optionals: Overwrites[]

Returns

Parser<unknown, MergeAll<[K in keyof Omit<A, Overwrites>]: A[K] & [K in keyof Pick<A, Overwrites>]?: A[K]>>

Type Parameters

A extends { }
Overwrites extends keyof A
Defaults extends [K in Overwrites]?: A[K]

Parameters

testShape: [key in keyof A]: Parser<unknown, A[key]>
optionals: Overwrites[]
defaults: Defaults

Returns

Parser<unknown, MergeAll<[K in keyof Omit<A, Overwrites>]: A[K] & [K in keyof Omit<Pick<A, Overwrites>, keyof Defaults>]?: A[K] & [K in keyof Pick<Pick<A, Overwrites>, keyof Defaults & Overwrites>]: A[K]>>

Type Parameters

A extends { }

Parameters

testShape: [key in keyof A]: Parser<unknown, A[key]>

Returns

Parser<unknown, A>