Skip to content

GramIO API Reference / gramio/dist / WithDerives

Type Alias: WithDerives<TThis, D>

WithDerives<TThis, D> = TThis extends EventComposer<infer TBase, infer TEventMap, infer TIn, infer TOut, infer TExposed, infer TDerives, infer TMethods, infer TMacros> ? EventComposer<TBase, TEventMap, TIn, TOut & D, TExposed, TDerives, TMethods, TMacros> & TMethods : never

Defined in: gramio/node_modules/composer/index.d.ts:421

Re-type a composer-like that has just added a global derive of shape D to its TOut. Preserves all other generics — TIn, TExposed, per-event TDerives, TMethods, TMacros — and re-applies & TMethods so subclass methods stay visible on the returned type.

Designed for subclass .derive(handler) overrides. The runtime work is still handled by super.derive(handler); this helper is type-only.

Type Parameters

Type Parameter
TThis
D extends object

Example

ts
class Scene extends SceneComposerBase {
  override derive<D extends object>(
    handler: DeriveHandler<ContextOf<this>, D>,
  ): WithDerives<this, D> {
    super.derive(handler);
    return this as unknown as WithDerives<this, D>;
  }
}