Repository: deno
Issue: JSDoc inline import with Deno LSP does not find or apply types from npm package
Labels: needs investigation,lsp

Version: Deno 2.1.3-1 on Arch Linux, kernel 6.6.63-1-lts

When using the Deno LSP (tested in both VSCode with Deno for VSCode v3.43.2 and neovim with coc-deno 3.15.0), JSDoc imports from npm packages are not working.
In the same project before initializing the Deno LSP, everything is found and functional with tsserver.

Steps to reproduce, in a new folder:
```bash
deno init
deno add npm:pg
deno add npm:@types/pg
touch index.js
```
This results in this deno.json:
```json
{
  "tasks": {
    "dev": "deno run --watch main.ts"
  },
  "imports": {
    "@std/assert": "jsr:@std/assert@1",
    "@types/pg": "npm:@types/pg@^8.11.10",
    "pg": "npm:pg@^8.13.1"
  }
}
```
In index.js:
```javascript
/**
 * @param {import('pg').}
 */
```
Removing the . after import('pg') and placing it back causes tsserver to give all types from @types/pg. Nothing happens with the Deno LSP.

The same exact thing can be seen with
```javascript
/**
 * @param {import('pg').Pool} pool
 */
const example = (pool) => {
  pool // Remove and type pool to see the intellisense
}
```
With the Deno LSP, the type for pool is:
```
(parameter) pool: any
@param - pool
```
With tsserver, the type is:
```
(parameter) pool: Pool
@param pool
```

---


# Deno Language Server Status

## Workspace Settings

```json
{
  "enable": true,
  "disablePaths": [],
  "enablePaths": null,
  "cache": null,
  "cacheOnSave": true,
  "certificateStores": null,
  "config": null,
  "importMap": null,
  "codeLens": {
    "implementations": false,
    "references": false,
    "referencesAllFunctions": false,
    "test": true
  },
  "internalDebug": false,
  "internalInspect": false,
  "logFile": false,
  "lint": true,
  "documentPreloadLimit": 1000,
  "suggest": {
    "imports": {
      "autoDiscover": true,
      "hosts": {
        "https://deno.land": true
      }
    }
  },
  "testing": {
    "args": [
      "--allow-all",
      "--no-check"
    ]
  },
  "tlsCertificate": null,
  "unsafelyIgnoreCertificateErrors": null,
  "unstable": [],
  "javascript": {
    "inlayHints": {
      "parameterNames": {
        "enabled": "none",
        "suppressWhenArgumentMatchesName": true
      },
      "parameterTypes": {
        "enabled": false
      },
      "variableTypes": {
        "enabled": false,
        "suppressWhenTypeMatchesName": true
      },
      "propertyDeclarationTypes": {
        "enabled": false
      },
      "functionLikeReturnTypes": {
        "enabled": false
      },
      "enumMemberValues": {
        "enabled": false
      }
    },
    "preferences": {
      "importModuleSpecifier": "shortest",
      "jsxAttributeCompletionStyle": "auto",
      "autoImportFileExcludePatterns": [],
      "useAliasesForRenames": true,
      "quoteStyle": "auto",
      "preferTypeOnlyAutoImports": false
    },
    "suggest": {
      "completeFunctionCalls": true,
      "includeAutomaticOptionalChainCompletions": true,
      "includeCompletionsForImportStatements": true,
      "names": true,
      "paths": true,
      "autoImports": true,
      "enabled": true,
      "classMemberSnippets": {
        "enabled": true
      },
      "objectLiteralMethodSnippets": {
        "enabled": true
      }
    },
    "updateImportsOnFileMove": {
      "enabled": "prompt"
    }
  },
  "typescript": {
    "inlayHints": {
      "parameterNames": {
        "enabled": "none",
        "suppressWhenArgumentMatchesName": true
      },
      "parameterTypes": {
        "enabled": false
      },
      "variableTypes": {
        "enabled": false,
        "suppressWhenTypeMatchesName": true
      },
      "propertyDeclarationTypes": {
        "enabled": false
      },
      "functionLikeReturnTypes": {
        "enabled": false
      },
      "enumMemberValues": {
        "enabled": false
      }
    },
    "preferences": {
      "importModuleSpecifier": "shortest",
      "jsxAttributeCompletionStyle": "auto",
      "autoImportFileExcludePatterns": [],
      "useAliasesForRenames": true,
      "quoteStyle": "auto",
      "preferTypeOnlyAutoImports": false
    },
    "suggest": {
      "completeFunctionCalls": true,
      "includeAutomaticOptionalChainCompletions": true,
      "includeCompletionsForImportStatements": true,
      "names": true,
      "paths": true,
      "autoImports": true,
      "enabled": true,
      "classMemberSnippets": {
        "enabled": true
      },
      "objectLiteralMethodSnippets": {
        "enabled": true
      }
    },
    "updateImportsOnFileMove": {
      "enabled": "prompt"
    }
  }
}
```

## Workspace Details

  - <details><summary>Documents in memory: 39</summary>

    - file:///home/myuser/Desktop/denoexample/.vim/coc-settings.json
    - file:///home/myuser/Desktop/denoexample/.vscode/settings.json
    - file:///home/myuser/Desktop/denoexample/deno.json
    - file:///home/myuser/Desktop/denoexample/index.js
    - file:///home/myuser/Desktop/denoexample/main.ts
    - file:///home/myuser/Desktop/denoexample/main_test.ts
    - https://jsr.io/@std/assert/1.0.10/almost_equals.ts
    - https://jsr.io/@std/assert/1.0.10/array_includes.ts
    - https://jsr.io/@std/assert/1.0.10/assert.ts
    - https://jsr.io/@std/assert/1.0.10/assertion_error.ts
    - https://jsr.io/@std/assert/1.0.10/equal.ts
    - https://jsr.io/@std/assert/1.0.10/equals.ts
    - https://jsr.io/@std/assert/1.0.10/exists.ts
    - https://jsr.io/@std/assert/1.0.10/fail.ts
    - https://jsr.io/@std/assert/1.0.10/false.ts
    - https://jsr.io/@std/assert/1.0.10/greater.ts
    - https://jsr.io/@std/assert/1.0.10/greater_or_equal.ts
    - https://jsr.io/@std/assert/1.0.10/instance_of.ts
    - https://jsr.io/@std/assert/1.0.10/is_error.ts
    - https://jsr.io/@std/assert/1.0.10/less.ts
    - https://jsr.io/@std/assert/1.0.10/less_or_equal.ts
    - https://jsr.io/@std/assert/1.0.10/match.ts
    - https://jsr.io/@std/assert/1.0.10/mod.ts
    - https://jsr.io/@std/assert/1.0.10/not_equals.ts
    - https://jsr.io/@std/assert/1.0.10/not_instance_of.ts
    - https://jsr.io/@std/assert/1.0.10/not_match.ts
    - https://jsr.io/@std/assert/1.0.10/not_strict_equals.ts
    - https://jsr.io/@std/assert/1.0.10/object_match.ts
    - https://jsr.io/@std/assert/1.0.10/rejects.ts
    - https://jsr.io/@std/assert/1.0.10/strict_equals.ts
    - https://jsr.io/@std/assert/1.0.10/string_includes.ts
    - https://jsr.io/@std/assert/1.0.10/throws.ts
    - https://jsr.io/@std/assert/1.0.10/unimplemented.ts
    - https://jsr.io/@std/assert/1.0.10/unreachable.ts
    - https://jsr.io/@std/internal/1.0.5/build_message.ts
    - https://jsr.io/@std/internal/1.0.5/diff.ts
    - https://jsr.io/@std/internal/1.0.5/diff_str.ts
    - https://jsr.io/@std/internal/1.0.5/format.ts
    - https://jsr.io/@std/internal/1.0.5/styles.ts

  </details>

  - <details><summary>Performance measures: 169</summary>

    - lsp.update_diagnostics_ts (210.96ms)
    - tsc.host.$getDiagnostics (210.764ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.002ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0ms)
    - tsc.op.op_is_node_file (0.001ms)
    - tsc.op.op_is_node_file (0.012ms)
    - tsc.op.op_load (0.016ms)
    - tsc.op.op_resolve (0.014ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.016ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.013ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.013ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.023ms)
    - tsc.op.op_load (0.017ms)
    - tsc.op.op_resolve (0.013ms)
    - tsc.op.op_load (0.015ms)
    - tsc.op.op_resolve (0.065ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.019ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.027ms)
    - tsc.op.op_load (0.015ms)
    - tsc.op.op_resolve (0.034ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.015ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.015ms)
    - tsc.op.op_load (0.011ms)
    - tsc.op.op_resolve (0.028ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.034ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.023ms)
    - tsc.op.op_load (0.02ms)
    - tsc.op.op_resolve (0.025ms)
    - tsc.op.op_load (0.014ms)
    - tsc.op.op_resolve (0.035ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.013ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.025ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.035ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.014ms)
    - tsc.op.op_load (0.013ms)
    - tsc.op.op_resolve (0.015ms)
    - tsc.op.op_load (0.015ms)
    - tsc.op.op_resolve (0.033ms)
    - tsc.op.op_load (0.017ms)
    - tsc.op.op_resolve (0.046ms)
    - tsc.op.op_load (0.021ms)
    - tsc.op.op_load (0.023ms)
    - tsc.op.op_load (0.014ms)
    - tsc.op.op_resolve (0.344ms)
    - tsc.op.op_load (0.021ms)
    - tsc.op.op_resolve (1.347ms)
    - tsc.op.op_load (0.022ms)
    - tsc.op.op_load (0.039ms)
    - tsc.op.op_load (0.016ms)
    - tsc.op.op_resolve (0.287ms)
    - tsc.op.op_load (0.021ms)
    - tsc.op.op_load (0.012ms)
    - tsc.op.op_resolve (0.025ms)
    - tsc.op.op_load (0.025ms)
    - tsc.op.op_resolve (5.378ms)
    - tsc.op.op_load (0.016ms)
    - tsc.op.op_resolve (1.668ms)
    - tsc.op.op_load (0.028ms)
    - tsc.op.op_resolve (0.17ms)
    - tsc.op.op_load (0.02ms)
    - tsc.op.op_script_names (0.026ms)
    - lsp.update_diagnostics_lint (0.6ms)
    - lsp.update_diagnostics_deps (0.197ms)
    - lsp.did_open (0.604ms)
    - lsp.update_cache (0.001ms)
    - lsp.update_global_cache (1.718ms)
    - lsp.initialize (63.442ms)
    - tsc.request.$getAssets (6.621ms)
    - tsc.host.$getAssets (5.017ms)
    - tsc.request.$getSupportedCodeFixes (54.092ms)
    - tsc.host.$getSupportedCodeFixes (0.318ms)

  </details>

## Performance (last 3 000 entries)

|Name|Count|Duration|
|---|---|---|
|lsp.did_open|1|0.604ms|
|lsp.initialize|1|63.442ms|
|lsp.update_cache|1|0.001ms|
|lsp.update_diagnostics_deps|1|0.197ms|
|lsp.update_diagnostics_lint|1|0.6ms|
|lsp.update_diagnostics_ts|1|210.96ms|
|lsp.update_global_cache|1|1.718ms|
|tsc.host.$getAssets|1|5.017ms|
|tsc.host.$getDiagnostics|1|210.764ms|
|tsc.host.$getSupportedCodeFixes|1|0.318ms|
|tsc.op.op_is_node_file|88|0.001ms|
|tsc.op.op_load|37|0.016ms|
|tsc.op.op_resolve|31|0.316ms|
|tsc.op.op_script_names|1|0.026ms|
|tsc.request.$getAssets|1|6.621ms|
|tsc.request.$getSupportedCodeFixes|1|54.092ms|

## Performance (total)

|Name|Count|Duration|
|---|---|---|
|lsp.did_open|1|0.604ms|
|lsp.initialize|1|63.442ms|
|lsp.update_cache|1|0.001ms|
|lsp.update_diagnostics_deps|1|0.197ms|
|lsp.update_diagnostics_lint|1|0.600ms|
|lsp.update_diagnostics_ts|1|210.960ms|
|lsp.update_global_cache|1|1.718ms|
|lsp.virtual_text_document|1|0.000ms|
|tsc.host.$getAssets|1|5.017ms|
|tsc.host.$getDiagnostics|1|210.764ms|
|tsc.host.$getSupportedCodeFixes|1|0.318ms|
|tsc.op.op_is_node_file|88|0.039ms|
|tsc.op.op_load|37|0.608ms|
|tsc.op.op_resolve|31|9.812ms|
|tsc.op.op_script_names|1|0.026ms|
|tsc.request.$getAssets|1|6.621ms|
|tsc.request.$getSupportedCodeFixes|1|54.092ms|