I have followed the below steps to generate the bug.
server.ts using the below command:import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
I have tried to bundle the code using the below command:
deno bundle server.ts server.bundle.js
Then I have tried to run the bundled code using the below command:
deno run server.bundle.js
After that, I have found the below issue into the terminal
error: Uncaught SyntaxError: Unexpected reserved word
for await (const req of s) {
~~~~~
at file:///Projects/Personal/server.bundle.js:5467:13
Top-level for await isn't supported in bundles at the moment. Duplicate of #4207.
I think the documentation can have a clue as you have mentioned. Then no one will create an issue again in the future.
Where would it make sense to put in the documentation?
Ultimately it is an upstream bug that we want to get fixed.
Where would it make sense to put in the documentation?
Ultimately it is an upstream bug that we want to get fixed.
as an info in http module
Ideal scenario is compiler shouldn't succeed with TypeErrors or at least should issue a warning. Having compiler and type checking in place renders useless if it lets type bugs pass through even in simple examples. If it's a known limit of Typescript it shouldn't compile at all
I do believe we are squashing the diagnostic message, and might not need to. This was because TypeScript didn't support top level await at all, although we supported it at runtime. The benefit of having it usable outweighed the particular issue.
Either way, this is a duplicate of #4207 and conversation should continue over there. @bartlomieju can we please close as duplicate?
Closing as duplicate, continue in #4207
Most helpful comment
I think the documentation can have a clue as you have mentioned. Then no one will create an issue again in the future.