Vscode_deno: Why vs code doesn't show types for Deno

Created on 1 Jun 2020  Â·  19Comments  Â·  Source: denoland/vscode_deno

I've installed this plugin, but when I try to write code, for example:

console.log(Deno.readDirSync("."));

vs code shows me an error:
Cannot find name 'Deno'.ts(2304)
I use built-in version of TypeScript. Do I need to download types somehow?

Most helpful comment

Hi @buttercubz , @filburt-turle
finally, it's working for me. I downloaded lib.deno.d.ts file, then I restarted the typescript server, restarted mac and it worked!
Thanks for the tips :)

All 19 comments

check if you have this file deno.d.ts
in windows C:\Users\userhere.deno
in linux /Users/deno/.deno

There is only bin folder there which contains of deno.zip that's all. I used chcolatelly for install and I have Windows 8.1 is it an install error propably? Will try to place this file, thank you!

I placed deno.d.ts file into C:\Users\userhere.deno but no effects. It still doesn't work.

Fixed by copying lib.deno.d.ts and lib.webworker.d.ts from

C:\Users\<User>\.vscode\extensions\denoland.vscode-deno-1.24.0\node_modules\typescript-deno-plugin\lib

to

C:\Users\<User>\AppData\Local\deno

Seems like extention wasn't able to copy it's dts files don't know why.

same here the scripts run normal but the types are missing

@Niyarlatotep
try to have deno updated to the latest version it is currently 1.0.4.

use deno upgrade --version 1.0.4

Hi,
I have version 1.0.4 of Deno. I'm using mac.

I installed and enabled the plugin: https://github.com/denoland/vscode_deno
Ts modules can be imported when the plugin is enabled.

But the Deno is not recognized.

I tried reinstalling the plugin.

In the settings I've added:
{
"deno.enable": true
}

I also tried:
{
"deno.enabled": true
}

I rebooted.

No luck.

There were no deno.d.ts installed anywhere. Do I need that file?

What else can I do?

@jbergant
as temporary fix you can try to copy
lib.deno.d.ts and lib.webworker.d.ts
from
~/.vscode/extensions/denoland.vscode-deno-1.24.0/node_modules/typescript-deno-plugin/lib
to
$HOME/Library/Caches/deno
as I mentioned before, but I'm not sure about Mac OS paths you can try. It worked for me on Windows

Hi @Niyarlatotep,

these two files were not installed on the mac during the installation.

After restarting my computer a few times, I can now run deno scripts in the terminal with no problem. The problem any remains in the IDE where I get the error: "Cannot find name 'Deno'."

@jbergant you can download lib.deno.d.ts file in this link from latest release.

this file contain all type definitions for Deno namespaces

@buttercubz I just downloaded the latest Deno and I'm having the same problems as @jbergant, vscode is not picking up the Deno and it's not showing the methods...

I'm running Version: 1.46.0-insider

Is there a manual way to get this working?

🦕 ~/D/deno ➜  find ./ -name lib.webworker.d.ts                           master
🦕 ~/D/deno ➜  find ./ -name lib.deno.d.ts                                master

Those files don't actually exist.

@filburt-turle try to restart typescript server in vscode or reinstall vscode_deno plugin

Hi @buttercubz , @filburt-turle
finally, it's working for me. I downloaded lib.deno.d.ts file, then I restarted the typescript server, restarted mac and it worked!
Thanks for the tips :)

I'm running VS Code 1.45.1 on macOS Catalina 10.15.4 using deno: 1.0.5, VS Code's own typescript server at 3.9.2 and v1.24.0 of the official denoland.vscode-deno plugin and I'm having the same problem.

I tried all the suggestions on this thread including re-downloading the latest lib.deno.d.ts into ~/.vscode/extensions/denoland.vscode-deno-1.24.0/node_modules/typescript-deno-plugin/lib/, restarting the typescript server and rebooting my Mac... to no avail.

However I did find a workaround thanks to this helpful StackOverflow answer. In short:

cd <my-project>
touch tsconfig.json
mkdir lib
deno types > lib/deno_runtime.d.ts 

Even if tsconfig.json is empty, it seems VS Code will automatically include deno_runtime.d.ts. Of course if you put anything else in there, you'll want to invoke deno with the --config option to ensure it uses your tsconfig.json rather than it's own.

@niyarlatotep solution worked for me.
Thank you

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.

It turns out that the issue was resolved by opening the command palette and running the Deno Init command on the bottom right.

Screen Shot 2020-12-15 at 8 07 52 AM

I'm running VS Code 1.45.1 on macOS Catalina 10.15.4 using deno: 1.0.5, VS Code's own typescript server at 3.9.2 and v1.24.0 of the official denoland.vscode-deno plugin and I'm having the same problem.

I tried all the suggestions on this thread including re-downloading the latest lib.deno.d.ts into ~/.vscode/extensions/denoland.vscode-deno-1.24.0/node_modules/typescript-deno-plugin/lib/, restarting the typescript server and rebooting my Mac... to no avail.

However I did find a workaround thanks to this helpful StackOverflow answer. In short:

cd <my-project>
touch tsconfig.json
mkdir lib
deno types > lib/deno_runtime.d.ts 

Even if tsconfig.json is empty, it seems VS Code will automatically include deno_runtime.d.ts. Of course if you put anything else in there, you'll want to invoke deno with the --config option to ensure it uses your tsconfig.json rather than it's own.

This worked for me. Cheers!

Was this page helpful?
0 / 5 - 0 ratings