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?
Hey, I just uninstalled justjavac's 1.32.0 and installed axetroy's 3.7.0 and it's working wonderful as expected. What's the matter with justjavac version? It's got like 16k downloads while 6k on axetroy's. How come so many people don't get this error?
@zemse Can you provide a tsserver.log file, I will fix this bug
Hi, here is the file. tsserver.log.
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.
@justjavac I've run into same problem again, I have "deno.enable": true, in the settings.json file but still it appears like if the plugin is not active. I tried disabling Deno using > Deno: Disable Deno and re-enabling it again. Also observed that enabling and disabling flips deno.enable boolean value too. Can you please look into my tsserver.log file?
Info 30 [23:42:6.187] Loading global plugin typescript-deno-plugin
Info 31 [23:42:6.187] Enabling plugin typescript-deno-plugin from candidate paths: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features,/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..
Info 32 [23:42:6.187] Loading typescript-deno-plugin from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features (resolved to /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules)
Info 33 [23:42:6.198] Loading typescript-deno-plugin from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../.. (resolved to /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/node_modules)
Info 34 [23:42:6.203] Failed to load module 'typescript-deno-plugin' from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules: Error: Could not resolve JS module 'typescript-deno-plugin' starting at '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules'. Looked in: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/index.jsx, /Applications/node_modules/typescript-deno-plugin/package.json, /Applications/node_modules/typescript-deno-plugin.js, /Applications/node_modules/typescript-deno-plugin.jsx, /Applications/node_modules/typescript-deno-plugin/index.js, /Applications/node_modules/typescript-deno-plugin/index.jsx, /node_modules/typescript-deno-plugin/package.json, /node_modules/typescript-deno-plugin.js, /node_modules/typescript-deno-plugin.jsx, /node_modules/typescript-deno-plugin/index.js, /node_modules/typescript-deno-plugin/index.jsx
at Object.resolveJSModule (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:29284:19)
at Object.sys.require (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:147642:45)
at Function.Project.resolveModule (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:139196:35)
at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:140205:36
at Object.firstDefined (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:197:26)
This extension will first look for typescript-deno-plugin in typescript-language-features, then look for it in justjavac.vscode-deno.
Judging from the log, it didn't look in the justjavac.vscode-deno installation directory, and reported an error directly.
When you open the ts file, did you see the Deno extension information in the status bar?

If it is a problem with the plugin installation, you can press Cmd + Shift + P, enter "openexlog", you will see the log file exthost.log
I do see Deno 1.0.2. While I was getting this too. Once again I checked that deno.enable is true in .vscode/settings.json.
This is the file exthost.log.

Few months ago in a different project, I did some setting in vscode to pick typescript version in ./node_modules/typescript in the vscode because a bug was fixed in latest typescript version and I wanted it instead of default typescript of vscode. Is it possible that this might be causing the problem? However, when I open a deno project, then I get a notification that vscode is using default typescript because it couldn't find the node_modules one.
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).
Getting the same issue with the "official" denoland.vscode-deno, but got it working with the deprecated justjavac.vscode-deno.
The denoland.Deno extension seems to be completely outdated compared to the justjavac.vscode-deno/
Do they share the same version numbers or is [email protected] === [email protected]?
e/
current denoland.vscode-deno works fine for me
@iMarv denoland.[email protected] !== justjavac.[email protected]
justjavac.[email protected] is the master branch of denoland/vscode_deno
well, it still doesnt working
I'm setting up Deno for the first time in a new project and the VSCode extension host log shows this error:
[2020-08-30 14:35:30.746] [exthost] [error] Activating extension denoland.vscode-deno failed due to an error:
[2020-08-30 14:35:30.753] [exthost] [error] Error: Cannot get typescript APIs. try restart Visual Studio Code.
at getTypescriptAPI (/Users/petepetrash/.vscode/extensions/denoland.vscode-deno-2.0.16/client/out/client/src/extension.js:31:17)
at Extension.activate (/Users/petepetrash/.vscode/extensions/denoland.vscode-deno-2.0.16/client/out/client/src/extension.js:268:28)
at Function._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:877:509)
at Function._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:877:160)
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:875:492
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Promise.all (index 2)
Restarting VSCode and re-installing the extension did not solve the issue. Using VSCode 1.48.2 and [email protected].
Started a new issue for this error: https://github.com/denoland/vscode_deno/issues/189
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.

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

Thank you @TranXuanHoang! It was so helpful to me.
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.
Most helpful comment
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).