Skip to content

InferProps is unknown for a defineHandler loader with middleware #489

Closed

Description

@ashunar0

Same kind of issue as #478. InferProps gives unknown when defineHandler gets middleware:

export const loader = defineHandler(auth, async (c) => {
  const book = await findBook(c.req.param('id'));
  if (!book) return c.notFound();
  return { book };
});

type Props = InferProps<typeof loader>;
// expected: { book: Book }
// actual:   unknown

The middleware overloads return TypedHandler without type arguments, so __output is unknown. The runtime already unwraps the return value as props, so only the type is wrong.

Returning TypedHandler<{}, Exclude<Awaited<R>, Response>> from the middleware overloads too, like the single-handler one, fixes it. Fix and type tests: ashunar0@61f7401

Happy to open a PR if that works for you.

Activity

  1. cpojer commented on Oct 19, 2026

    @cpojer
    Member

    Please send a PR!

  2. added a commit that references this issue on Oct 19, 2026
    4270ac0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions