cloudflare / workers-sdk

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

🚀 Feature Request: `wrangler types` should use union types for possible values #6931

Open luisrudge opened 1 week ago

luisrudge commented 1 week ago

Describe the solution

wrangler.toml

[vars]
SEND_EMAILS_ENABLED = "false"

[env.preview.vars]
SEND_EMAILS_ENABLED = "true"

[env.production.vars]
SEND_EMAILS_ENABLED = "true"

when I run wrangler types, it creates this interface:

interface Env {
    SEND_EMAILS_ENABLED: "false";
}

which causes a type error because the type is not 'false' | 'true' or even string.

image

So the values need to be generated with all the possible values, and not with only the local value.

emily-shen commented 1 week ago

cc @andyjessop