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

Inconsistency with deno check when using deno.json and npm dependencies whose exported type alias references another npm package #1205

Open
EqualMa opened this issue Nov 11, 2024 · 1 comment

Comments

@EqualMa
Copy link

EqualMa commented Nov 11, 2024

Describe the bug

npm package a has export interface Type<T> { ... }

npm package b depends on a and has export type Type<T> = import("a").Type;

My workspace is using deno.json and this vscode extension.
A file in my workspace has const _: import("b").Type<boolean> = 1;
deno check reports a type error as expected.
Vscode also reports it when first opening this workspace or after Deno: Restart Language Server.
But after navigating to the import("b").Type<boolean>, vscode no longer reports this error.
And when I hover the Type, it resolves to any.

Workarounds I have tried:

  • import("npm:b") doesn't fix it.
  • import("npm:b") and removing deno.json deno.lock fixes it.

I haven't tested whether this would happen using jsr or http with deno.json.

To Reproduce

  1. Create a new folder, with .vscode/settings.json enabling deno, and open it with vscode.
  2. Create a file main.ts with content const _: import("npm:@ipld/dag-pb").ByteView<boolean> = 1;
  3. deno add npm:@ipld/dag-pb
  4. deno check main.ts reports a type error
  5. Open main.ts in vscode, it might reports this error. But after navigating into the type ByteView and come back, it no longer reports the error.

I made a repo https://github.com/EqualMa/deno-vscode-inconsistency so you can open it directly.

Expected behavior

Vscode should resolve the re-exported Type correctly and reports the type error as deno check does.

Screenshots

When I first open the workspace, there is a type error as expected:
image

When I navigate into ByteView and come back, there is no error.
Screenshot 2024-11-11 at 16 05 24

Versions

vscode: 1.95.2 deno: 2.0.6 extension: v3.42.0

@schnetzlerjoe
Copy link

schnetzlerjoe commented Dec 3, 2024

Similar issue. Messing around with it, when you delete deno.json and deno.lock ,this fixes it. Otherwise the error/warning highlighter only works sometimes with successfully cancelled request with ID: 13 being seen often in logs.

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

No branches or pull requests

2 participants