-
Notifications
You must be signed in to change notification settings - Fork 757
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
Add support for new bindings to wrangler types #5089
Conversation
🦋 Changeset detectedLatest commit: eed80d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
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.
LGTM 😃 🚀 ❤️
if (configToDTS.ai) { | ||
// The @cloudflare/ai package types specify any, but from its usage | ||
// we can infer it's a Fetcher type (await this.binding.fetch) | ||
envTypeStructure.push(`${configToDTS.ai.binding}: Fetcher;`); |
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'd be tempted to keep it as any
if it is in @cloudflare/ai
🤔
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 think this should probably be any
/unknown
since I'm not sure it's guaranteed to always be a Fetcher
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'd like to avoid generating any
into user projects - lots of people use the recommended preset from typescript-eslint which includes no-explicit-any. unknown
is somewhat better, I haven't thought of that myself. Let me push a fix
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.
yes I would also go with unknown
, I didn't suggest it as I don't know if @cloudflare/ai
could complain about that?
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.
Fortunately anything can be passed to any
, including unknown: ts playground
Changed to unknown in b69e965
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-wrangler-5089 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5089/npm-package-wrangler-5089 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-wrangler-5089 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-create-cloudflare-5089 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-cloudflare-kv-asset-handler-5089 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-miniflare-5089 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-cloudflare-pages-shared-5089 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8158618486/npm-package-cloudflare-vitest-pool-workers-5089 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5089 +/- ##
==========================================
+ Coverage 70.31% 70.39% +0.07%
==========================================
Files 298 298
Lines 15551 15567 +16
Branches 4001 4007 +6
==========================================
+ Hits 10935 10958 +23
+ Misses 4616 4609 -7
|
send_email: config.send_email, | ||
vectorize: config.vectorize, | ||
hyperdrive: config.hyperdrive, | ||
mtls_certificates: config.mtls_certificates, | ||
browser: config.browser, | ||
ai: config.ai, |
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.
Can we change the type of this object to make sure we catch issues like this in the future? It should be something like Omit<EnvironmentNonInheritable, "define" | "unsafe" | "tail_consumers" | "constellation" | "cloudchamber">
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.
Added in 2e14c86
if (configToDTS.ai) { | ||
// The @cloudflare/ai package types specify any, but from its usage | ||
// we can infer it's a Fetcher type (await this.binding.fetch) | ||
envTypeStructure.push(`${configToDTS.ai.binding}: Fetcher;`); |
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 think this should probably be any
/unknown
since I'm not sure it's guaranteed to always be a Fetcher
@DaniFoldi looks like this is failing type checking? Would you be able to fix these failures? |
Of course, I'll remove |
ef301a6
to
eed80d3
Compare
Rebased on main, test failures seemed unrelated. Could you please take another look, @mrbbot? |
Fixes # [insert GH or internal issue number(s)].
What this PR solves / how to test:
This PR adds support for Email Send, Vectorize, Hyperdrive, mTLS, Browser Rendering and Workers AI bindings to
wrangler types
.Author has addressed the following:
Note for PR author:
We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label
highlight pr review
so future reviewers can take inspiration and learn from it.