Skip to content

fix(types): add ASSETS to the env types - #496

Merged
Brooooooklyn merged 3 commits into
voidzero-dev:mainfrom
meganemura:fix/assets-binding-type
Oct 20, 2026
Merged

Brooooooklyn merged 3 commits into
voidzero-dev:mainfrom
meganemura:fix/assets-binding-type

Conversation

@meganemura

@meganemura meganemura commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Void always binds ASSETS, but CloudBindings and Cloudflare.Env do not declare it. A route that reads a static file fails the type check:

export const GET = defineHandler((c) => c.env.ASSETS.fetch(c.req.raw));
// error TS18046: 'c.env.ASSETS' is of type 'unknown'.

What this PR changes

ASSETS: Fetcher is added to CloudBindings and Cloudflare.Env.

Decisions

On Node, the ASSETS stand-in has only fetch. Fetcher follows the other bindings, which use the Cloudflare types as they are. If you prefer Pick<Fetcher, 'fetch'>, I can change it.

Testing

env-types-typecheck.test.ts now calls c.env.ASSETS.fetch(). It fails on main and passes with this change.

🤖 Generated with Claude Code

meganemura and others added 2 commits October 19, 2026 13:54
Void always binds ASSETS, but CloudBindings and Cloudflare.Env do not
declare it, so c.env.ASSETS has type unknown.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZxFCFRcYc9ojkUsSvuz5j
…tput

Also list ASSETS with the other binding types in the docs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@Brooooooklyn

Copy link
Copy Markdown
Member

Thanks! I pushed f49841a on top:

  • Fetcher is right; please keep it. wrangler types declares an assets binding as ASSETS: Fetcher, and when two Cloudflare.Env declarations merge, the property types must be identical. With Pick<Fetcher, "fetch">, an app that also has wrangler types output fails with TS2717: Subsequent property declarations must have the same type.
  • Test: env-types-typecheck.test.ts now also reads ASSETS from Cloudflare.Env, and runs a second time with a wrangler types-style declaration. I checked that each case fails when its type is removed or changed.
  • Docs: ASSETS is now listed with the other binding types (api/types.md, api/env.md, integrations/cloudflare.md).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T07:25:01.553793Z d11b271 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f49841a78c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/src/runtime/handler.ts Outdated
…rget has

Node, Bun and Deno targets inject an ASSETS object whose fetch takes only
a Request, so the full Fetcher let handlers type-check calls that fail
there. Cloudflare.Env keeps Fetcher to merge with wrangler types output.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: d11b2718a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn
Brooooooklyn merged commit ed01e45 into voidzero-dev:main Oct 20, 2026
18 checks passed
@meganemura
meganemura deleted the fix/assets-binding-type branch October 20, 2026 11:17
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