deno/resolvers/node
Nathan Whitaker 08f5e797b6
fix(check/lsp): fall back to @types/* packages if npm package doesn't have types (#28185)
Fixes https://github.com/denoland/deno/issues/27569.
Fixes https://github.com/denoland/deno/issues/27215.

This PR makes it so type resolution falls back to looking for definitely
typed packages (`@types/foo`) if a given NPM package does not contain
type declarations.

One complication is choosing _which_ version of the `@types/*` package
to use, if the project depends on multiple versions. The heuristic here
is to try to match the major and minor versions, falling back to the
latest version. So if you have
```
@types/foo: 0.1.0, 0.2.0, 3.1.0, 3.1.2, 4.0.0
foo: 3.1.0
```
we would choose `@types/foo@3.1.2` when resolving types for `foo`.

---

Note that this only uses `@types/` packages if you _already_ depend on
them. So a follow up to this PR could be to add a diagnostic and
quickfix to install `@types/foo` if we don't find types for `foo`.
2025-02-19 23:55:06 +00:00
..
analyze.rs fix(check): npm resolution errors to tsc diagnostics (#28174) 2025-02-18 21:44:49 +00:00
builtin_modules.rs feat(ext/node): implement node:sqlite (#27308) 2025-01-28 19:30:03 +05:30
cache.rs perf: node resolution cache (#27838) 2025-02-03 20:25:10 -05:00
Cargo.toml 2.2.0 (#28175) 2025-02-18 23:12:17 +00:00
clippy.toml refactor: move ByonmNpmResolver to deno_resolver (#25937) 2024-09-30 13:33:32 +00:00
errors.rs fix(check/lsp): fall back to @types/* packages if npm package doesn't have types (#28185) 2025-02-19 23:55:06 +00:00
lib.rs fix(check/lsp): fall back to @types/* packages if npm package doesn't have types (#28185) 2025-02-19 23:55:06 +00:00
npm.rs perf(node_resolver): reduce url to/from path conversions (#27839) 2025-01-27 15:23:20 -05:00
package_json.rs perf(node_resolver): reduce url to/from path conversions (#27839) 2025-01-27 15:23:20 -05:00
path.rs perf(node_resolver): reduce url to/from path conversions (#27839) 2025-01-27 15:23:20 -05:00
README.md refactor: extract out sloppy imports resolution from CLI crate (#25920) 2024-09-28 19:17:48 -04:00
resolution.rs fix(check/lsp): fall back to @types/* packages if npm package doesn't have types (#28185) 2025-02-19 23:55:06 +00:00
sync.rs refactor: make PackageJsonCache injectable (#27800) 2025-01-24 09:50:25 -05:00

Node Resolver

crates docs

Provides Node.js compatible resolution for the Deno project.