Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing support for hono variables in the handler #34

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions platforms/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export type WorkflowBindings = {
*/
export const serve = <
TInitialPayload = unknown,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
TBindings extends WorkflowBindings = WorkflowBindings,
TVariables extends object = object,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a type-level the exact same, but I suggest using the Variables type provided directly by Hono:

import { Variables } from "hono/types"

>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
): ((context: Context<{ Bindings: TBindings }>) => Promise<Response>) => {
const handler = async (context: Context<{ Bindings: TBindings }>) => {
): ((context: Context<{ Bindings: TBindings; Variables: TVariables }>) => Promise<Response>) => {
const handler = async (context: Context<{ Bindings: TBindings; Variables: TVariables }>) => {
const environment = context.env;
const request = context.req.raw;

Expand Down
Loading