Skip to content

Fix Zod v4 async function type inference in schema definitions - #458

Closed
xuyushun441-sys with Copilot wants to merge 3 commits into
copilot/fix-action-step-error-yet-againfrom
copilot/fix-issue-in-action-run
Closed

xuyushun441-sys with Copilot wants to merge 3 commits into
copilot/fix-action-step-error-yet-againfrom
copilot/fix-issue-in-action-run

Conversation

Copilot AI commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor

Zod v4's z.function() with z.promise() output incorrectly infers MaybeAsync<T> (union of T | Promise<T>) instead of Promise<T>, causing TypeScript errors in plugin and event handler schemas:

// Before: Type error - MaybeAsync<void> not assignable to Promise<void>
storage: z.object({
  set: z.function({
    input: z.tuple([]).rest(z.any()),
    output: z.promise(z.void())  // Infers as () => void | Promise<void>
  }),
})

// After: Correct async inference
storage: z.object({
  set: createAsyncFunctionSchema(
    z.function({
      input: z.tuple([]).rest(z.any()),
      output: z.promise(z.void())  // Infers as () => Promise<void>
    })
  ),
})

Changes

  • Added createAsyncFunctionSchema helper in shared/zod-helpers.ts that wraps function schemas with z.custom<> to leverage Zod v4's implementAsync type parameter for correct Promise inference

  • Updated async function definitions in:

    • system/plugin.zod.ts: Plugin lifecycle hooks and storage methods
    • system/events.zod.ts: Event handler functions
    • system/job.zod.ts: Job handler functions

See: colinhacks/zod#4143

Original prompt

引用: https://github.com/objectstack-ai/spec/actions/runs/21559032847/job/62120041921#step:8:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel

vercel Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Feb 1, 2026 7:53am

Request Review

…ype inference

Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue in action run for specs Fix Zod v4 async function type inference in schema definitions Feb 1, 2026
Copilot AI requested a review from xuyushun441-sys February 1, 2026 07:53

This branch was successfully deployed

1 active deployment
Preview — ad25ab9e Deployed Feb 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants