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
- Fix broken installation of TS definition files for `Deno`. Fix wrong VS Code Extension ID. Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, before the e... — committed to denisbrodbeck/vscode_deno by denisbrodbeck 4 years ago
- Fix broken installation of TS definition files for `Deno`. (#77) Fix wrong VS Code Extension ID. Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, befor... — committed to denoland/vscode_deno by denisbrodbeck 4 years ago
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 documentationCreate a directory named
.vscode
and then create asettings.json
file inside that directory. Put the following JSON config in that fileyour-project-workspace/.vscode/settings.json
Open VS Code Settings
File > Preferences > Settings
(orCtr + ,
on Windows /Cmd + ,
on macOS). Searchdeno
, then selectExtensions > Deno
fron the search result filter.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
I just called
> Deno: Enable Deno
on your plugin, and it created a.vscode
dir containingI 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:
Still it would be nice if the Deno extension did that for you as it claims to.
Just tried the solution mentioned here, and it worked 💯. Thanks for sharing!
Perhaps
init deno
will solve the problem: Invscode
“show all commands” via CMD/CTRL + SHIFT + P and search forinit deno
, run it. Helped me to solve all problems with shown errors in vscode with deno.