Skip to content

fix(api): clean Vercel function typecheck (process + viem overloads)#4

Merged
gamween merged 1 commit into
mainfrom
fix/vercel-api-typecheck
Jun 16, 2026
Merged

fix(api): clean Vercel function typecheck (process + viem overloads)#4
gamween merged 1 commit into
mainfrom
fix/vercel-api-typecheck

Conversation

@gamween

@gamween gamween commented Jun 16, 2026

Copy link
Copy Markdown
Owner

What

The Vercel build log showed 8 TypeScript errors in api/onboard.ts:

  • Cannot find name 'process'
  • viem overload unions degraded (abi: anyreadContract demanded authorizationList, sendTransaction demanded kzg)

They were non-fatal — the deployment still went Ready and the relayer works (probed live: GET /api/onboard → 405, POST {} → 400 bad owner, i.e. deployed + RELAYER_PRIVATE_KEY set). But they dirtied the build and would become fatal if Vercel ever tightens.

Root cause

@vercel/node type-checks the function by discovering the nearest tsconfig.json from the function directory (ts.findConfigFile). The repo only had a non-standard site/tsconfig.api.json, which Vercel never reads — so the function was checked with the app-style resolution (types: ["vite/client"], no node types). That:

  1. excluded @types/nodeprocess undefined;
  2. broke abitype resolution → parseAbi(...) typed as any → viem picked the wrong overload union members.

Fix

  • Move the api tsconfig to site/api/tsconfig.json — the exact path @vercel/node discovers. types: ["node"] + Bundler resolution makes abitype resolve → typed ABIs → correct viem overloads.
  • Add an idiomatic /// <reference types="node" /> to the function (belt-and-suspenders for process, independent of whichever config is used).
  • Repoint typecheck:apitsc -p api/tsconfig.json so CI checks the same config Vercel uses (closes the gap that hid this).

Verification

  • tsc auto-discovery from api/ (mimics @vercel/node) → clean
  • pnpm typecheck:api, pnpm lint, pnpm build → all green

No runtime change to the relayer — types only.

Vercel's @vercel/node type-checks api/onboard.ts by discovering the nearest
tsconfig from the function dir (ts.findConfigFile). The repo only had a
non-standard site/tsconfig.api.json, never read by Vercel, so the function was
checked with the app-style resolution (no node types) — surfacing 8 errors:
  - 5x 'Cannot find name process' (types field excluded @types/node)
  - viem overload unions degraded (abi: any -> readContract wanted
    authorizationList, sendTransaction wanted kzg)
These were non-fatal (deploy still succeeded) but dirtied the build.

Fix: move the api tsconfig to site/api/tsconfig.json (the location @vercel/node
discovers) and add an idiomatic /// <reference types=node /> to the function.
Under this config viem's abitype resolves -> typed abi -> correct overloads.

Verified: tsc auto-discovery from api/ is clean; typecheck:api, lint, build all green.
Copilot AI review requested due to automatic review settings June 16, 2026 22:43
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
coincoin Ready Ready Preview, Comment Jun 16, 2026 10:43pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gamween gamween merged commit e1c3fb1 into main Jun 16, 2026
5 checks passed
@gamween gamween deleted the fix/vercel-api-typecheck branch June 16, 2026 22:45
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