LSP: Import specifier remapping should prefer exact matches
I'm currently using the postgres library, which I've mapped using the following in my imports of import-map.json. I use both the exact name, as well as the prefix, so that I can refer to submodules in that package as postgres/foo/bar.ts for example.
"postgres": "https://deno.land/x/[email protected]/mod.ts",
"postgres/": "https://deno.land/x/[email protected]/",
Now, in some module in my code, I import postgres:
import { Client } from "postgres";
import { QueryArguments, QueryObjectResult } from "postgres/query/query.ts";
On the first line, where I've imported Client, I see the following suggestion:
Resolved Dependency
Code: https://deno.land/x/postgres@v0.17.0/mod.ts
The import specifier can be remapped to "postgres/mod.ts" which will
resolve it via the active import map.deno(import-map-remap)
I would think that an exact match, postgres should take precedence over the relative mapping, or if the relative mapping is the prefered way to handle these, then maybe a lint rule that suggests I don't add both an exact AND a relative import mapping for the same library.
I'm commonly encountering this issue with imports of vendored libraries, where the suggested change is relative to the root directory.
Import map:
"~/": "./",
"zipjs": "./vendor/zipjs.ts",
Import suggests remapping to "~/vendor/zipjs.ts":
import { type Entry, ZipReader } from 'zipjs'