-
Notifications
You must be signed in to change notification settings - Fork 330
feat: add Props type parameter to ExportedHandler for typed ctx.props #784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add a Props type parameter to ExportedHandler so that ctx.props can be properly typed when using `satisfies ExportedHandler<Env, Props>`. - Add enhanced ExportedHandler<Env, Props, QueueHandlerMessage, CfHostMetadata> - Add Props-aware handler types (ExportedHandlerFetchHandler, etc.) - Export types from main entry point and agents/types - Add generic params to createMcpHandler and McpAgent.serve() Fixes cloudflare#501
🦋 Changeset detectedLatest commit: 4d75bb3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should be typing these here. These are already defined in the output of wrangler types if I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick reply! I want to make sure I understand the concern. Are you saying wrangler types already generates ExportedHandler with a Props parameter? I added Props support to enable typed ctx.props which I don't believe exists in the current wrangler types output. Should these types live elsewhere, or should I be extending the wrangler generated types differently?
| } | ||
|
|
||
| export function createMcpHandler( | ||
| export function createMcpHandler< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a good improvement independently of the types below.
Add a Props type parameter to ExportedHandler so that ctx.props can be properly typed when using
satisfies ExportedHandler<Env, Props>.Fixes #501