`wrangler types` breaks VS Code typing
I ran
pnpm wrangler types (Wrangler 4.40.1) and it added a new GlobalProps interface to my worker-configuration.d.ts. This appears to break types in VS Code - I now get Property 'Foo' does not exist on type 'Env' errors for all my bindings and environment variables (screenshot).
Manually editing worker-configuration.d.ts to remove the GlobalProps import makes the VS Code errors go away. How can I fix?

18 Replies
Can you share a full screenshot of the interface Env generated by Wrangler? Starts at line 8 in your worker-configuration.d.ts

Alright, thanks! I just wanted to ensure that the binding type was correctly generated
I avoid adding manual edits to the
worker-configuration.d.ts file as it will be overwritten if you generate new types and bindings with Wrangler. What do you want to acheive by adding the GlobalProps interface?wrangler is adding GlobalProps, not me. My screenshot shows the output of
wrangler types, diffed against the previous (working) version.
To try and investigate the issue, I manually edited the worker-configuration.d.ts to remove GlobaProps interface, and typing immediately reappeared in VS Code.Ah, you're right. Let me see if I can reproduce this in a worker project on my end
I bumped my Worker project to latest wrangler and generated types, but I am not seeing the issue on my end.
What does your Worker Entrypoint look like (
src/index)?Not sure I can post it all, but the entrypoint is below - then
fetch and scheduled are ExportedHandlerFetchHandler<Env> and ExportedHandlerScheduledHandler<Env> functions.
I also have a separate, much simpler Worker project - just a fetch handler which responds with data from an R2 bucket. In that project, running wrangler types also outputs this GlobalProps interface - but it doesn't cause any problems, VS Code typing is fine, bindings are picked upDoes that project also use Sentry?
I did recently install this package https://www.npmjs.com/package/cloudflare and wonder if there's maybe some namespace issue?
nope
Just to try to pinpoint the the issue, if you remove the Sentry export and just keep the minimal fetch and scheduled exports, does that change anything?
nope
Hmm, I am not sure, hard to debug without being able to reproduce. Perhaps someone with more in-depth knowledge of the type generation can help if they see this.
thanks. do you know if there's anywhere i should be looking for logs of type generation errors? the
Output > Typescript pane in VS Code doesn't have anythinghello, I have also faced this issue @Olaf | CDN/Developer Platform
I have a reproduction here.
https://github.com/sebws/cf-sentry-issue-repo
@Matthew have you had any luck with this?
GitHub
GitHub - sebws/cf-sentry-issue-repo
Contribute to sebws/cf-sentry-issue-repo development by creating an account on GitHub.
ah good work creating a repro! maybe this should be reported to sentry, if it's increasingly looking like a sentry issue
no i did nothing more - just commented out GlobalProps for now 😬
i suppose I can do that 😋
i just realised i dont think the extra library with cloudflare types installed was necessary for showing the error. makes it seem very Sentry related
GitHub
[sentry/cloudflare] Sentry import breaks Env type · Issue #16099 ...
Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Hi! I tried your test and was unable to reproduce the error using pnpm, not sure what's going on but I've never seen this error in any of projects. Seems like someone faced this a while ago and reported it to Sentry on github
hey, curious that you couldn't reproduce, but it seems to me that the github sentry issue is the same.
they are saying that for it to be fixed, their prs fixing cloudflare types need to be fixed. not sure if that's true or not but 🤷