`InferProps` keeps `Promise` and `Response` for a `withValidator` loader
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
首先阅读 defineHandler.withValidator 的返回类型,以及 InferProps 如何读取 __output。为一个返回 { book } 或 Response 的 loader 添加类型测试,并检查 InferProps<typeof loader> 是否解析为 { book: Book },而不是 promise 或 response 的联合类型。
由索引模型根据 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 分钟
- 30 天内合并 PR
- 77
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
voidzero-dev/void#463 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
voidzero-dev/void#459 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1-3 小时 新手友好度 78/100
voidzero-dev/void#428 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
voidzero-dev/void#480 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 56/100
voidzero-dev/void#477 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)可能已有人在做 @Jxxunnn 今天认领。 未关闭Browser Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 82/100
getsentry/sentry-javascript#25497 · 1 条评论 ·
维护者通常 1 天内回复
-
e2e-failure ready-to-code
难度 2/5 1-3 小时 新手友好度 77/100
redhat-developer/rhdh-plugin-export-overlays#4438 · 1 条评论 ·
维护者通常 1 天内回复
-
resource: destroying a resource calls AbortController.abort() without a reason, creating an AbortError with a stack trace each time可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area: core
难度 2/5 1-3 小时 新手友好度 75/100
angular/angular#71422 · 1 条评论 ·
维护者通常 1 天内回复
-
bug status: needs triage
难度 2/5 1-3 小时 新手友好度 72/100
facebook/docusaurus#12739 · 1 条评论 ·
维护者通常 1 天内回复
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
难度 1/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复