cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.72k stars 713 forks source link

🐛 BUG: `wrangler types` copies actual string from wrangler.toml instead of the type #7273

Open shmuli9 opened 2 hours ago

shmuli9 commented 2 hours ago

Which Cloudflare product(s) does this pertain to?

Wrangler

What version(s) of the tool(s) are you using?

3.86.1 & 3.87.0 [Wrangler]

What version of Node are you using?

20.15.0

What operating system and version are you using?

Windows 11

Describe the Bug

Observed behavior

When running wrangler types the worker-configuration.d.ts is wrongly populated with the actual value in the wrangler.toml instead of setting up the types

Expected behavior

When running wrangler types the worker-configuration.d.ts is sets up the types to reflect the types of values in the wrangler.toml

Steps to reproduce

Please provide the following:

wrangler.toml

[vars]
SERVER_ADDRESS = "http://localhost:3000/event"
BUCKET_NAME ="my-bucket"
CLOUDFLARE_ACCOUNT_ID="XXXXX"
ACCESS_KEY_ID="XXXXX"

worker-configuration.d.ts

// Generated by Wrangler by running `wrangler types`

interface Env {
    SERVER_ADDRESS: "http://localhost:3000/event";
    BUCKET_NAME: "my-bucket";
    CLOUDFLARE_ACCOUNT_ID: "XXXXX";
    ACCESS_KEY_ID: "XXXXX";
    SECRET_ACCESS_KEY: string;
    BUCKET: R2Bucket;
    DB: D1Database;
    QUEUE: Queue;
}

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

shmuli9 commented 2 hours ago

This seems to be related https://github.com/cloudflare/workers-sdk/issues/5082

shmuli9 commented 2 hours ago

The only way to fix this seems to be by defining the variables in .dev.vars as well - this causes the types to be properly generated