vscode_deno icon indicating copy to clipboard operation
vscode_deno copied to clipboard

Jupyter kernel on vscode gives error about variables declared on above cells

Open ceifa opened this issue 9 months ago • 13 comments

To Reproduce

  1. Open deno kernel on vscode
  2. Create a variable in the first cell
  3. Use it on the second one

Expected behavior

None errors

Screenshots

image

Versions

vscode: 1.82.2 deno: 1.37 extension: v3.23.1

@bartlomieju

ceifa avatar Sep 21 '23 21:09 ceifa

@nayeemrmn could you take a look what's going on here?

bartlomieju avatar Sep 22 '23 09:09 bartlomieju

This will happen in the deno language server isn't being used - try adding "deno.enable": true to your settings and see if the error goes away.

It looks like you can also put your notebooks in a specific directory and add that directory to deno.enablePaths as recommended in the setting description.

amunger avatar Sep 29 '23 16:09 amunger

But I would say it should be safe for the extension to always use the deno language server for a notebook that has a deno kernel selected.

amunger avatar Sep 29 '23 16:09 amunger

But I would say it should be safe for the extension to always use the deno language server for a notebook that has a deno kernel selected.

I agree. Specifically because I don't want deno to be enabled on the global settings and I also don't want to save the notebook file sometimes.

ceifa avatar Sep 29 '23 16:09 ceifa

I'm also seeing this issue and have "deno.enable": true in my .vscode/settings.json.

ghing avatar Dec 05 '23 21:12 ghing

i'm wondering how this could be solved implementation-wise. my naive first impression was:

  1. join all typescript cells
  2. send the joined cell into tsc
  3. parse tsc diagnostics and re-map line numbers into splitted cells

scarf005 avatar Dec 10 '23 00:12 scarf005

I forgot to give an update here, this is blocked by https://github.com/gluon-lang/lsp-types/pull/268 which implements this API in the protocol https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notebookDocument_synchronization. This provides the minimum of getting the accurate order of the cells etc.

After that it's still going to be difficult and we'd likely have to do what @scarf005 proposed above. On the surface this isn't a problem with VSCode's built-in node TS server because it has notebook cells in script mode, where all vars are global. We might alternatively end up doing something similar.

nayeemrmn avatar Dec 10 '23 00:12 nayeemrmn

Would this PR help somehow? https://github.com/denoland/deno/pull/21518

bartlomieju avatar Dec 12 '23 11:12 bartlomieju

I'm also seeing this issue and have "deno.enable": true in my .vscode/settings.json.

Same here. The Deno APIs are enabled as shown by this screenshot: image

Jupyter support is the only reason why I started using Deno, and this issue is a blocker for me.

pekam avatar Jan 08 '24 11:01 pekam

What a pitty, I was so excited to try out Deno inside of jupyter notebooks but having variables that don't remember their values makes it a no go. And yes, Deno is enabled in this workspace. image

Hexodus avatar Feb 10 '24 13:02 Hexodus

Just as a reminder, the code does work as expected, this issue is just about the lsp giving wrong diagnostics, but if you run the cell it will work.

sigmaSd avatar Feb 10 '24 14:02 sigmaSd

Just as a reminder, the code does work as expected, this issue is just about the lsp giving wrong diagnostics, but if you run the cell it will work.

Unfortunately, even if it does execute, it's frustrating to lose all type information and be downgraded to any after the first cell. So, no code completion or type checking, effectively losing all benefits of typescript. Any ETA on when this might be fixed?

vanb avatar Mar 02 '24 18:03 vanb

Anyone have a work-around for this?

As it stands, it's nearly unusable. :(

dnszero avatar Apr 15 '24 16:04 dnszero