Skip to content

Conversation

@ghostwriternr
Copy link
Member

@ghostwriternr ghostwriternr commented Dec 1, 2025

Users extending Sandbox to add custom methods would get a type error when passing their namespace to getSandbox(). TypeScript's generic invariance meant the function couldn't accept subclass namespaces. getSandbox and SandboxEnv are now generic to properly support extended classes.

Fixes #262

Fixes type error when extending Sandbox class.
DurableObjectNamespace<T> is invariant, so getSandbox
needed to be generic to accept subclass namespaces.
@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

🦋 Changeset detected

Latest commit: 00bbd01

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/sandbox 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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/sandbox-sdk/@cloudflare/sandbox@264

commit: 00bbd01

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

🐳 Docker Images Published

Default (no Python):

FROM cloudflare/sandbox:0.0.0-pr-264-03385c9

With Python:

FROM cloudflare/sandbox:0.0.0-pr-264-03385c9-python

Version: 0.0.0-pr-264-03385c9

Use the -python variant if you need Python code execution.

agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Dec 1, 2025
Update API documentation to reflect TypeScript generic type parameters
added to getSandbox(), SandboxEnv, and proxyToSandbox(). These changes
fix type errors when extending the Sandbox class with custom methods.

Changes:
- Update getSandbox() signature to show generic type parameter
- Add section on extending Sandbox class with example
- Document proxyToSandbox() function with generic types
- Document SandboxEnv type helper for custom Sandbox classes

Related to cloudflare/sandbox-sdk#264

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
claude[bot]

This comment was marked as off-topic.

Copy link
Collaborator

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

generally should we use unknown instead of any?

@ghostwriternr ghostwriternr merged commit 8601b5c into main Dec 4, 2025
19 checks passed
@ghostwriternr ghostwriternr deleted the improve-entrypoint-types branch December 4, 2025 13:41
@github-actions github-actions bot mentioned this pull request Dec 4, 2025
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.

Friction log

2 participants