Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@PeterDaveHello
Copy link
Contributor

Summary

Problem

PR #5107 upgraded core-schemas to Zod v4 and attempted to use:

z.function({ input: z.tuple([]), output: z.promise(...) })

This syntax is incorrect for Zod v4 because:

  • In Zod v4, z.function() is a function factory, not a schema
  • It cannot be used inside z.object()
  • Causes DTS build errors: "Object literal may only specify known properties, but 'input' does not exist"

References:

Solution

Use z.custom<T>() with runtime validator:

pollFn: z.custom<() => Promise<unknown>>((val) => typeof val === "function")
onProgress: z.custom<(current: number, total: number) => void>((val) => typeof val === "function")

This approach:

  • ✅ Fixes DTS build errors
  • ✅ Preserves TypeScript type inference
  • ✅ Adds runtime function validation (Zod best practice)

Why CI Didn't Catch This

CI runs pnpm check-types which executes tsc --noEmit and does detect the error.

However, Turbo's remote cache caused the check to be skipped:

  1. PR fix(core-schemas): upgrade to Zod v4 for CLI compatibility #5107 only changed package.json (dependency version)
  2. Turbo cached the type check results from before the breaking change
  3. Subsequent PRs didn't modify core-schemas files
  4. Cache kept being reused, CI never actually ran type check

Verification

Before (main branch):

$ pnpm build
# DTS Build error
src/auth/kilocode.ts(36,23): error TS2561: Object literal may only specify known properties, 
but 'input' does not exist

After (this PR):

$ pnpm build
# DTS ⚡️ Build success

Test Plan

  • Type check passes: pnpm check-types
  • Build succeeds: pnpm build (ESM, CJS, DTS all pass)
  • Type inference verified: PollingOptions type still correct
  • Runtime validation added: typeof val === "function"

cc #5107

…n Zod v4

Fixes DTS build errors introduced in PR Kilo-Org#5107 where z.function() was used
with incorrect Zod v4 syntax.

## Problem

PR Kilo-Org#5107 upgraded core-schemas to Zod v4 and used z.function({ input, output })
syntax, but this is incorrect for Zod v4:
- In Zod v4, z.function() is a function factory, not a schema
- It cannot be used inside z.object()
- This causes DTS build errors: "Object literal may only specify known properties,
  but 'input' does not exist"

See:
- Zod v4 changelog: https://zod.dev/v4/changelog#zfunction
- Official workaround: colinhacks/zod#4143

## Solution

Use z.custom<T>() with runtime validator for function types:
- pollFn: z.custom<() => Promise<unknown>>((val) => typeof val === "function")
- onProgress: z.custom<(current: number, total: number) => void>((val) => typeof val === "function")

This approach:
- Fixes DTS build errors
- Preserves type inference
- Adds runtime function validation (following Zod best practices)

cc Kilo-Org#5107
@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: 011be57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@kilocode/core-schemas Patch
kilo-code Patch
@kilocode/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants