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

[BUG] lsp dts importmap #17829

Closed
loynoir opened this issue Feb 20, 2023 · 3 comments
Closed

[BUG] lsp dts importmap #17829

loynoir opened this issue Feb 20, 2023 · 3 comments

Comments

@loynoir
Copy link

loynoir commented Feb 20, 2023

Brief

Within importmap context, dts should resolve to dts of target file, instead of dts of source file.

Edit: Not sure what happend, but I guess it's dts problem on lsp side.

Reproduce

import_map.json

{
  "imports": {
    "comment-json": "npm:[email protected]",
    "fs/promises": "https://deno.land/[email protected]/node/fs/promises.ts",
    "node:fs/promises": "https://deno.land/[email protected]/node/fs/promises.ts"
  }
}

Actual

Within vscode, below code type error on importId comment-json

import { parse, stringify } from 'comment-json'
console.log({ parse, stringify })
import { readFile, writeFile } from 'node:fs/promises'
console.log({ readFile, writeFile })
Resolved Dependency

Code: npm​:comment-json​@4.2.3

Uncached or missing npm package: "[email protected]".deno(no-cache-npm)

denoland.vscode-deno deno language server log have many repeated same error, @types/node not found

Could not set npm package requirements.  \
Error getting response at https://registry.npmjs.org/@types/node: \
An npm specifier not found in cache: "@types/node", --cached-only is specified.

Expected

Within vscode, below code types are OK

import { parse, stringify } from 'comment-json'
console.log({ parse, stringify })
import { readFile, writeFile } from 'node:fs/promises'
console.log({ readFile, writeFile })

Workaround

Within vscode, below code types are OK

import { parse, stringify } from 'comment-json'
console.log({ parse, stringify })
import { readFile, writeFile } from 'fs/promises'
console.log({ readFile, writeFile })

Edit

Above workaround, offen works, sometimes still got type error on comment-json

@loynoir loynoir changed the title [BUG] importmap and type resolve [BUG] lsp dts importmap Feb 20, 2023
@bartlomieju
Copy link
Member

Run Cache dependencies from the command pallete and the error should go away.

@loynoir
Copy link
Author

loynoir commented Feb 20, 2023

@bartlomieju

  • I cache them,
  • and extension show warning on comment-json,
  • then I check lsp log, found lsp complaning missing @types/node,
Could not set npm package requirements.  \
Error getting response at https://registry.npmjs.org/@types/node: \
An npm specifier not found in cache: "@types/node", --cached-only is specified.
  • repeat cache serverl times and different timepoint, still found issue reproduceable.
  • repeat restart deno server, still found issue reproduceable.
  • so I create the issue.
  • If I did not cache them, the workaround should never works, instead of often works.

@loynoir
Copy link
Author

loynoir commented Feb 22, 2023

The errors are gone.

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