Type Alias: Args<R *extends* Registry, C *extends* Code<R>>
No args for a bare code, else optional/required per Meta's required keys. Gated on the value's own Carries brand, not on Meta, since a bare code's Meta resolves to {} which anything would satisfy.
Args<
RextendsRegistry,CextendsCode<R>> =R[C] extendsCarries<any> ? [HasRequired<Meta<R,C>>] extends [never] ? [Meta<R,C>] : [Meta<R,C>] : []
Defined in: kit.ts:61
No args for a bare code, else optional/required per Meta's required keys. Gated on the value's own Carries brand, not on Meta, since a bare code's Meta resolves to {} which anything would satisfy.
Type Parameters
R
R extends Registry
C
C extends Code<R>
Example
const REGISTRY = {
TEST_BARE: 500, // Args -> []
TEST_DETAIL: detail<{ field: string }>(400), // Args -> [meta: { field: string }]
TEST_DETAIL_NO_ARG: detail(400), // no <M> given -> Args -> [] (behaves like bare)
} as const satisfies Record<string, number>
const TestError = createErrorKit('TestError', REGISTRY).ErrorClass
new TestError('TEST_BARE') // ok, no second argument
// @ts-expect-error a code that carries something cannot be raised without it
new TestError('TEST_DETAIL')
new TestError('TEST_DETAIL', { field: 'x' }) // ok