-
Notifications
You must be signed in to change notification settings - Fork 690
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
npm create cloudflare onboarding experience is very rough #3742
Comments
Update: I retried this today and it looks like my compat date was set to |
A user running into similar issues and confusion: https://community.cloudflare.com/t/workers-compatibility-date-issue/548087?u=cherryjimbo |
I am not sure if this is related but I just ran
currently working around with |
Hit this rough onboarding experience again today when spinning up a new worker. I created a new TypeScript worker using C3, with gave me a fresh worker with a if (navigator.userAgent === 'Cloudflare-Workers') { but was immediately hit with a typescript error:
I eventually realised this was due to my I had to stop and think for quite some time when I hit https://www.npmjs.com/package/@cloudflare/workers-types too. My compat date is |
@Cherry I've created a separate issue for the workers-types problem, that we'll look into addressing soon 🙂 Please have a look and let me know there if you think that will help 🙏
Yes, my understanding is that that's how things currently work, I agree that it is quite confusing 😓, the team is aware of it and hopefully will look into improving the situation at some point soon-ish. |
Not sure if this is also related, but I just tried making a new hello world TS project with C3 and got no typescript installed at all:
Shouldn't this be a .ts file that shows how to use |
In the meantime if folks are struggling with C3, I'd recommend
|
Cleaning up the backlog, I think the issues in the original bug report have been resolved. If not, please feel free to file a follow up issue. |
Which Cloudflare product(s) does this pertain to?
C3
What version(s) of the tool(s) are you using?
2.1.0
What version of Node are you using?
18.17.1
What operating system are you using?
Windows
Describe the Bug
I just spun up a brand new project using create cloudflare and ran into a pretty rough onboarding experience with DX.
npm create cloudflare@latest
- use all defaultswrangler.toml
compat date is set to2023-08-12
(the current date)@cloudflare/workers-types
version in mypackage.json
is^4.20230419.0
- 3 months oldtsconfig.json
types
includes@cloudflare/workers-types
default with no compat date (so sometime in 2021)typescript
is set to^5.0.4
despite wrangler (via esbuild) not supporting most (any?) TypeScript 5 featuresNow if you try do something like this in your worker, it'll work at runtime because your compat date is modern, but your types are old so you get errors when treating things as a
File
in dev:And you also get warnings like this (related: cloudflare/miniflare#666):So then, to get my environment in a working state without type errors, and warnings, I had to go figure out the latest "supported" compat date, and workers types version I could actually use.
This seems to be
2022-11-30
for types, so I have to update mytsconfg.json
to include@cloudflare/workers-types/2022-11-30
instead. I knew exactly where to look to find this, understanding the compat date/flag concepts, but the same is unlikely to be said for new users - this being a different date to my compat date is very weird.And then forworkerd
it seems to be2023-08-07
so now I have to update mywrangler.toml
too so this removes the miniflare warning.It ALSO sets my
typescript
version to5.x
which implies I'm able to use newer TypeScript syntax like this (not real world, but simple example using const type paramaters):This passes all type checking and is valid with TypeScript 5.x, so my editor is fine with it. But when I try and run, I get weird syntax errors due to the old
esbuild
version wrangler is using. Related: #2980So now, as a user to get my development environment into a completely functional state, I have to specifically change my types to match a compat date,
change my compat date to a "supported" one,and then also make sure I'm not writing any actual code that's TypeScript 5 syntax, or downgrade to TypeScript 4, assuming I have a deep enough understanding of everything to come to those conclusions. Once ALL of that is done, I can finally get to actually writing my worker without errors and warnings.All of these things in isolation seem reasonable, but as an ecosystem this doesn't feel very coherent right now unfortunately.
The text was updated successfully, but these errors were encountered: