Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`InferProps` keeps `Promise` and `Response` for a `withValidator` loader

オープン 初心者向け
#478 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript

調査の方向性

まず、defineHandler.withValidator の戻り値の型と、InferProps が __output をどのように読み取るかを確認してください。{ book } または Response を返す loader の型テストを追加し、InferProps<typeof loader> が promise または response の union ではなく { book: Book } に解決されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

InferProps gives the props of a defineHandler loader, but not of a defineHandler.withValidator one:

export const loader = defineHandler.withValidator({
  params: z.object({ id: z.string() }),
})(async (c, { params }) => {
  const book = await findBook(params.id);
  if (!book) return c.notFound();
  return { book };
});

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

defineHandler returns TypedHandler<{}, Exclude<Awaited<R>, Response>>, but withValidator returns TypedHandler<V, R> with the raw R. Routes don't notice, because the generated types wrap the output in Serialize<Awaited<…>>. InferProps reads __output directly, so it breaks.

Returning Exclude<Awaited<R>, Response> from withValidator too fixes it. Fix and a type test: https://github.com/ashunar0/void/commit/07c5352d58f880a0c77b78ce38aa5fb6fc832d5f

Happy to open a PR if that works for you.

主要言語
TypeScript
スター
402
フォーク
32
平均マージ
12時間 28分
マージ済み PR(30日)
77

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

voidzero-dev/void のほかの issue

voidzero-dev/void の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。