Open ramesaliyev opened 1 month ago
I'd push back against this. It's not wrangler's purview to enforce type checking (should it fail? warn? should it support all of tsc's flags? etc etc.) That said, maybe the templates generated could include an npm script entry that calls tsc --no-Emit? dunno.
That said, the issue you pointed out with kv-asset-handler seems not directly related. Could you expand on that more? typechecking is failing in the workers-sdk repo for you? Or in a generated app?
Yeah maybe my wording is a little bit off here. What I actually meant is that when I generate a worker app with typescript by using npm create cloudflare
, the generated app should do type checking before deployment. This can be achieved adding custom builds entry to generated wrangler.toml
which performs tsc --noEmit
like you said.
About the second issue, just ignore it, it was my fault, edited the original issue.
We are considering adding a wrangler check
command that would do type checking (among other things). We could then consider whether a C3 template would run this before wrangler deploy
if the user is actually using TypeScript...
Describe the solution
Hello!
Wrangler uses esbuild for bundling and since esbuild does not do any type checking (see evanw/esbuild#1631) no errors are produced if there is something wrong. This kinda defeats the purpose.
From esbuild's documentation on TypeScript:
I believe
tsc --noEmit
or something else needs to be a part ofwrangler deploy
. Or at least this information, and a solution, should be added to somewhere in documentation. Maybe somewhere in Bundling .Because I only noticed this by chance. There may be some people out there who are not aware of this.
I'll post my current solution in case someone else needs it.
I've added a custom build to my wrangler.toml which basically does this.