DenoDDeno
Powered by
tacoT
Denoβ€’15mo ago
taco

JSDoc inline import with Deno LSP does not find or apply type from npm package

Hello!
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.

I'm running Deno 2.1.3-1 on Arch Linux, kernel 6.6.63-1-lts

Steps to reproduce, in a new folder:
deno init
deno add npm:pg
deno add npm:@types/pg
touch index.js
deno init
deno add npm:pg
deno add npm:@types/pg
touch index.js

This results in this deno.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"
  }
}
{
  "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:
/**
 * @param {import('pg').}
 */
/**
 * @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
/**
 * @param {import('pg').Pool} pool
 */
const example = (pool) => {
  pool // Remove and type pool to see the intellisense
}
/**
 * @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
(parameter) pool: any
@param - pool

With tsserver, the type is:
(parameter) pool: Pool
@param pool
(parameter) pool: Pool
@param pool


The deno LSP status is in the attached text.
message.txt12.49KB
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

jsdoc `@import` ignored by `deno check` but not by LSP
strmnnSstrmnn / help
2y ago
Deno does not recognize npm import
weegeeWweegee / help
3y ago
Deno LSP Issue with import maps?
ZidanZZidan / help
2y ago
Deno: How to import npm scoped packages with @ in deno?
Alex AdventAAlex Advent / help
3y ago