question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Top-level 'await' is not recognized by extension

See original GitHub issue

I have installed latest Deno extenstion version from VSCode marketplace and everything is ok except the top-level await statements. It seems that extension just does not recognize them:

image

Output of deno --version command:

❯ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2

VSCode version:

❯ code --version
1.42.1
c47d83b293181d9be64f27ff093689e8e7aed054
x64

OS: macOS Mojave 10.14.6 18G2022 x86_6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
detjcommented, Aug 16, 2020

I’m seeing ts(1378) instead of ts(1308). Not sure if what I’m getting is directly related to this issue or not.

Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.ts(1378)

Here are the steps I followed:

  1. Installed the extension
  2. Created .vscode/settings.json with following entry
{
  "deno.enable": true,
  "[typescript]": {
    "editor.defaultFormatter": "denoland.vscode-deno"
  }
}
  1. Wrote a basic oak server
import { Application } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

app.use((ctx) => {
  console.log("received request", ctx.request);
  ctx.response.body = "Hello World!";
});

console.log("oak server listening at http://localhost:8000");

await app.listen("127.0.0.1:8000"); // ts(1378) triggering on this line

image

Here are the version details:

$ deno --version
deno 1.3.0
v8 8.6.334
typescript 3.9.7

VSCode is also using TypeScript v3.9.7

0reactions
lucacasonatocommented, Feb 19, 2021

Should be resolved in version 3.x of the extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

await Error at Top Level Module in Chrome Extension ...
Chrome forbids top-level await in a service worker intentionally. It can't be circumvented, so you'll have to use an async function. – wOxxOm....
Read more >
Top-level await is available in Node.js modules - Stefan Judis
mjs file extension to use it in my scripts. Renaming a script file from js to mjs is quickly done and is not...
Read more >
How to use top-level await in JavaScript - Flavio Copes
Learn how to use this new feature currently available in v8.
Read more >
How to use top-level await in Node.js - YouTube
This is a video about top-level await in Node.js. Top-level await is available in ECMAscript modules in Node.js. You can use it in...
Read more >
top level await expressions are only allowed
To solve the error "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext'", use the await keyword...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found