fix(api): clean Vercel function typecheck (process + viem overloads)#4
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Vercel build log showed 8 TypeScript errors in
api/onboard.ts:Cannot find name 'process'abi: any→readContractdemandedauthorizationList,sendTransactiondemandedkzg)They were non-fatal — the deployment still went
Readyand the relayer works (probed live:GET /api/onboard→ 405,POST {}→ 400bad owner, i.e. deployed +RELAYER_PRIVATE_KEYset). But they dirtied the build and would become fatal if Vercel ever tightens.Root cause
@vercel/nodetype-checks the function by discovering the nearesttsconfig.jsonfrom the function directory (ts.findConfigFile). The repo only had a non-standardsite/tsconfig.api.json, which Vercel never reads — so the function was checked with the app-style resolution (types: ["vite/client"], no node types). That:@types/node→processundefined;abityperesolution →parseAbi(...)typed asany→ viem picked the wrong overload union members.Fix
site/api/tsconfig.json— the exact path@vercel/nodediscovers.types: ["node"]+ Bundler resolution makesabityperesolve → typed ABIs → correct viem overloads./// <reference types="node" />to the function (belt-and-suspenders forprocess, independent of whichever config is used).typecheck:api→tsc -p api/tsconfig.jsonso CI checks the same config Vercel uses (closes the gap that hid this).Verification
tscauto-discovery fromapi/(mimics@vercel/node) → cleanpnpm typecheck:api,pnpm lint,pnpm build→ all greenNo runtime change to the relayer — types only.