Skip to content
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

fix: make wrangler types always generate a d.ts file for module worders #5087

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

dario-piotrowicz
Copy link
Member

What this PR solves / how to test:

Currently if a config file doesn't define any binding nor module, running
wrangler types against such file would not produce a d.ts file.

Producing a d.ts file can however still be beneficial as it would define a correct
env interface (even if empty) that can be expanded/referenced by user code (this can
be particularly convenient for scaffolding tools that may want to always generate an
env interface).

Example:
Before wrangler types --env-interface MyEnv run with an empty wrangler.toml file
would not generate any file, after these change it would instead generate a file with
the following content:

interface MyEnv {
}

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because: this is a quality of life improvement that doesn't require documentation

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.

@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner February 24, 2024 18:10
Copy link

changeset-bot bot commented Feb 24, 2024

🦋 Changeset detected

Latest commit: 9a9974d

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers 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

Copy link
Contributor

github-actions bot commented Feb 24, 2024

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/8053372881/npm-package-wrangler-5087

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5087/npm-package-wrangler-5087

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-wrangler-5087 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-create-cloudflare-5087 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-cloudflare-kv-asset-handler-5087
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-miniflare-5087
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-cloudflare-pages-shared-5087
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8053372881/npm-package-cloudflare-vitest-pool-workers-5087

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.29.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240208.0
workerd 1.20240208.0 1.20240208.0
workerd --version 1.20240208.0 2024-02-08

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link

codecov bot commented Feb 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.38%. Comparing base (cab7e1c) to head (9a9974d).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5087      +/-   ##
==========================================
+ Coverage   70.33%   70.38%   +0.04%     
==========================================
  Files         298      298              
  Lines       15515    15516       +1     
  Branches     3987     3988       +1     
==========================================
+ Hits        10913    10921       +8     
+ Misses       4602     4595       -7     
Files Coverage Δ
packages/wrangler/src/type-generation.ts 99.20% <100.00%> (+<0.01%) ⬆️

... and 6 files with indirect coverage changes

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
@dario-piotrowicz dario-piotrowicz merged commit a5231de into main Mar 4, 2024
17 checks passed
@dario-piotrowicz dario-piotrowicz deleted the wrangler-types-empty-env branch March 4, 2024 17:18
@workers-devprod workers-devprod mentioned this pull request Mar 4, 2024
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