Skip to content

MacroTypeLambda

PropertyDescription
contextThe call-site schema and accumulated singleton context, excluding output from macros selected at the same call site
input-

Defined in: elysia/dist/types.d.ts:813

Type-level lambda applied to a macro’s per call site hook value

Return type as $type: macroType<Lambda>() output will be added to route’s context

A function-form macro may also compute option from this['context']. The hook value is then typed as option per route, guard, group and ws, replacing the macro’s declared parameter

this is not allowed in a nested type literal

interface LiveOption<Context> { topic?: (ctx: Context) => string }
interface Live extends MacroTypeLambda { option: LiveOption<this['context']> }
new Elysia().macro({
live: (option: LiveOption<Context>) => ({
$type: macroType<Live>(),
beforeHandle() {}
})
})
context: unknown;

Defined in: elysia/dist/types.d.ts:819

The call-site schema and accumulated singleton context, excluding output from macros selected at the same call site


input: unknown;

Defined in: elysia/dist/types.d.ts:814

Last updated:

Type to search the documentation.

    Up arrowDown arrow to navigateEnter to selectEscape to close