denoland / denoland/vscode_deno
feat: Support IntelliSense autocomplete for valid registries when using import map specifiers
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 169
- PR merge metrics
- No merged PRs in 30d
Description
I would like to see IntelliSense autocompletion for imports from valid registries when those registries have been mapped to arbitrary specifiers using an import map.
I'm aware that this issue is being tracked in the CLI repo in regard to LSP support at [this issue](https://github.com/denoland/deno/issues/10951). I'm creating an issue here in this repo specifically for tracking behavior about the extension in VS Code, and to document the current behavior (below).
I have an example directory structure like this:
```
% ls -AF
.vscode/ import_map.json
deno.jsonc main.ts
% cat .vscode/settings.json
{
"deno.enable": true
}
% cat deno.jsonc
{
"importMap": "./import_map.json"
}
% cat import_map.json
{
"imports": {
"std/": "https://deno.land/std@0.166.0/"
}
}
% cat main.ts
% deno --version
deno 1.28.2 (release, x86_64-apple-darwin)
v8 10.9.194.1
typescript 4.8.3
```
If I open the directory as a workspace in VS Code, and then open the file `main.ts` in an editor tab, and begin to type an import statement which uses the full URL for the standard library specifier in the import map, I get IntelliSense autocompletions. Here's a screenshot example to illustrate:

However, If I try to use the import map specifier for the same registry, the IntelliSense does not provide autocompletions beyond the specifier itself. It is aware that the mapped specifier exists:

But doesn't provide any further suggestions:

Further observations:
If I type out the complete path for a valid module in the registry using the literal URL, the module is cached as soon as I stop typing, without even needing to save the file:

But when using the import map specifier path to a module, I get a diagnostic signal (red wavy underlines) with conflicting information in the [quick info](https://code.visualstudio.com/docs/editor/intellisense) box — it states that the dependency is resolved, but _also_ that it is uncached or missing:

I must manually save the file and invoke the [palette command](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) "Deno: Cache Dependencies" in order to resolve the diagnostic issue:

I would, of course, like to see this behavior for `export` statements as well.
---
Related:
- https://github.com/denoland/vscode_deno/issues/348
- https://github.com/denoland/deno/issues/10951
- https://github.com/denoland/deno/issues/11168
- https://github.com/denoland/deno/issues/16805
Contributor guide
Research direction
Reproduce the behavior in main.ts using deno.jsonc, import_map.json, and the .vscode/settings.json configuration with Deno enabled. Compare IntelliSense for the literal registry URL and the mapped specifier, including import and export statements; done means mapped valid registries provide completions and do not report an uncached or missing dependency before manually running “Deno: Cache Dependencies”.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100