iceghost
iceghost6mo ago

Transitive dependencies with node_modules

Hi all, today I stumbled upon this not-sure-if-a-bug:
import { LRParser } from "npm:@lezer/lr@1.3.14";
import { LRLanguage } from "npm:@codemirror/language@6.9.3";

LRLanguage.define({
parser: LRParser.deserialize(undefined),
});
import { LRParser } from "npm:@lezer/lr@1.3.14";
import { LRLanguage } from "npm:@codemirror/language@6.9.3";

LRLanguage.define({
parser: LRParser.deserialize(undefined),
});
Checking the lock file, there is no duplicated package with different version. Running without nodeModulesDir config works, but otherwise, typescript has this error:
Type 'import("file:///tmp/deno-test/node_modules/.deno/@lezer+lr@1.3.14/node_modules/@lezer/lr/dist/index").LRParser' is not assignable to type 'import("file:///tmp/deno-test/node_modules/.deno/@codemirror+language@6.9.3/node_modules/@lezer/lr/dist/index").LRParser'.
Type 'import("file:///tmp/deno-test/node_modules/.deno/@lezer+lr@1.3.14/node_modules/@lezer/lr/dist/index").LRParser' is not assignable to type 'import("file:///tmp/deno-test/node_modules/.deno/@codemirror+language@6.9.3/node_modules/@lezer/lr/dist/index").LRParser'.
Should I report this bug? (I can live without toggling node_modules for now)
1 Reply
Deno AI Helper
Deno AI Helper6mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the message you've provided, it seems like there might be a type conflict or a path resolution issue due to the way TypeScript is resolving the types from the node_modules directory. The error message suggests that TypeScript is treating the two imports of LRParser as coming from different locations, which could happen if the package is duplicated in the dependency tree or if there's a misconfiguration in the TypeScript path resolution. Since this advice is not based on the Deno documentation, please double-check the accuracy of this advice. If you continue to experience issues, you might want to consider reporting the bug with a detailed description of the problem, including the error message and your configuration, so that the Deno team can investigate further.