vscode_deno: Installed VSCode plugin but still not able to catch deno syntax

Following the tutorial in the docs:

const res = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const body = new Uint8Array(await res.arrayBuffer());
await Deno.stdout.write(body);

I still get underline on the await:

'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.ts(1375)

And underline on the Deno

Cannot find name 'Deno'.ts(2304)

while if I run the file with deno, it obv runs. But vscode underlines are very irritating as well as it is not giving any type suggestions for Deno object.

I installed the plugin Deno 1.32.0 by justjavac. I tried doing [command]+[p] and > Enable Deno, which says deno is already enabled.

I tried to find any similar issue but seems it’s not there while my issue is very basic regarding installation. I went through Readme but not able to solve the problem. Can you please help me what more I need to do to get it working?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (5 by maintainers)

Commits related to this issue

Most upvoted comments

And underline on the Deno

Cannot find name 'Deno'.ts(2304)

I have this same issue in VS Code. I can see ‘Deno 1.0.2’ on the status bar, and other Deno syntax (such as import, await) seems to work (VS Code doesn’t report problems on them, only on the Deno name so far).

I got the same phenomenal in which Deno code suggestion and autocompletion did not work after installing denoland’s vscode_deno. After trying around I found the following steps help VS Code understands Deno - though this isn’t a configuration recommended by the plugin’s official documentation

  • Create a directory named .vscode and then create a settings.json file inside that directory. Put the following JSON config in that file

    your-project-workspace/.vscode/settings.json

    {
      "deno.enable": true,
    }
    
  • Open VS Code Settings File > Preferences > Settings (or Ctr + , on Windows / Cmd + , on macOS). Search deno, then select Extensions > Deno fron the search result filter. image

  • Check the Controls whether Deno is enabled or not to enable Deno like the above image capture.

  • Restart VS Code, and hopefully Deno suggestion and autocompletion will work image

I just called > Deno: Enable Deno on your plugin, and it created a .vscode dir containing

{
  "deno.enable": true
}

I did try this yesterday, enable and disable a number of times while .vscode dir wasn’t being created.

But now it is being created, making the plugin’s work. Looks like there isn’t any issue from the plugin side and maybe this mac just went silly and needed a restart 😦 My bad, pardon for the trouble. Closing the issue.

Ah you can manually set this in your workspace settings:

"typescript.validate.enable": false,
"javascript.validate.enable": false,

Still it would be nice if the Deno extension did that for you as it claims to.

Perhaps init deno will solve the problem: In vscode “show all commands” via CMD/CTRL + SHIFT + P and search for init deno, run it. Helped me to solve all problems with shown errors in vscode with deno.

Just tried the solution mentioned here, and it worked 💯. Thanks for sharing!

Perhaps init deno will solve the problem: In vscode “show all commands” via CMD/CTRL + SHIFT + P and search for init deno, run it. Helped me to solve all problems with shown errors in vscode with deno.