> await Deno.permissions.query({ name: "read" })
error: Uncaught SyntaxError: await is only valid in async function
â–º <unknown>:1:1
at evaluate ($deno$/repl.ts:84:34)
at replLoop ($deno$/repl.ts:175:13)
Node seems to be using a (async () => { ${src} })() wrapper for this. But they also explicitly used a JS parser to ensure that there is no top-level return along with this await (which breaks the wrapper)
TLA only works in V8 module contexts - because the REPL is a traditional script context it can't do TLA.
Same root cause as #1285. (https://github.com/denoland/deno/issues/1285#issuecomment-454900436) - if the REPL will move to a module context, which would be nice, this would work out of the box. For now we could do the same as chrome dev tools and node which both just wrap the call in an async function.
if the REPL will move to a module context, which would be nice, this would work out of the box
I think that would be hard, because a module needs to be "closed" so its imports and exports and be analysed. It would effectively need to rerun the whole "module" every time a line is added. Only script contexts can really be open-ended like that, which means a few things have to be frigged.
if the REPL will move to a module context, which would be nice, this would work out of the box
I think that would be hard, because a module needs to be "closed" so its imports and exports and be analysed. It would effectively need to rerun the whole "module" every time a line is added. Only script contexts can really be open-ended like that, which means a few things have to be frigged.
Yeah. And running a module again and again might yield unexpected repeated side effects (e.g. console.log multiple times)
Most helpful comment
TLA only works in V8 module contexts - because the REPL is a traditional script context it can't do TLA.
Same root cause as #1285. (https://github.com/denoland/deno/issues/1285#issuecomment-454900436) - if the REPL will move to a module context, which would be nice, this would work out of the box. For now we could do the same as chrome dev tools and node which both just wrap the call in an async function.