Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why vs code doesn't show types for Deno #74

Closed
niyarlatotep opened this issue Jun 1, 2020 · 19 comments · Fixed by #77
Closed

Why vs code doesn't show types for Deno #74

niyarlatotep opened this issue Jun 1, 2020 · 19 comments · Fixed by #77

Comments

@niyarlatotep
Copy link

niyarlatotep commented Jun 1, 2020

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?

@buttercubz
Copy link

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

@niyarlatotep
Copy link
Author

niyarlatotep commented Jun 2, 2020

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!

@niyarlatotep
Copy link
Author

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

@chenguzhen87
Copy link

you can reference #62

@niyarlatotep
Copy link
Author

niyarlatotep commented Jun 2, 2020

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.

@zzhenryquezz
Copy link

same here the scripts run normal but the types are missing

@buttercubz
Copy link

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

use deno upgrade --version 1.0.4

@jbergant
Copy link

jbergant commented Jun 3, 2020

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?

@niyarlatotep
Copy link
Author

niyarlatotep commented Jun 3, 2020

@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

@jbergant
Copy link

jbergant commented Jun 3, 2020

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'."

@buttercubz
Copy link

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

this file contain all type definitions for Deno namespaces

@filburt-turle
Copy link

filburt-turle commented Jun 3, 2020

@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.

@buttercubz
Copy link

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

@jbergant
Copy link

jbergant commented Jun 4, 2020

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 :)

@followben
Copy link

followben commented Jun 5, 2020

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.

@adamledwards
Copy link

@niyarlatotep solution worked for me.
Thank you

denisbrodbeck added a commit to denisbrodbeck/vscode_deno that referenced this issue Jun 6, 2020
Fix wrong VS Code Extension ID.
Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, before the extension finishes activation phase.

fixes denoland#74, denoland#66, denoland#62, denoland#48
@ry ry closed this as completed in #77 Jun 6, 2020
ry pushed a commit that referenced this issue Jun 6, 2020
Fix wrong VS Code Extension ID.
Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, before the extension finishes activation phase.

fixes #74, #66, #62, #48
@kevinXmichael
Copy link

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.

@k3v3n
Copy link

k3v3n commented Dec 15, 2020

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

@webpreneur
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.