mirror of
https://github.com/denoland/deno.git
synced 2025-03-10 14:17:49 -04:00

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`.
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
|
|
#![deny(clippy::print_stderr)]
|
|
#![deny(clippy::print_stdout)]
|
|
|
|
pub mod analyze;
|
|
mod builtin_modules;
|
|
pub mod cache;
|
|
pub mod errors;
|
|
mod npm;
|
|
mod package_json;
|
|
mod path;
|
|
mod resolution;
|
|
|
|
mod sync;
|
|
|
|
pub use builtin_modules::DenoIsBuiltInNodeModuleChecker;
|
|
pub use builtin_modules::IsBuiltInNodeModuleChecker;
|
|
pub use builtin_modules::DENO_SUPPORTED_BUILTIN_NODE_MODULES;
|
|
pub use cache::NodeResolutionCache;
|
|
pub use cache::NodeResolutionCacheRc;
|
|
pub use deno_package_json::PackageJson;
|
|
pub use npm::InNpmPackageChecker;
|
|
pub use npm::NpmPackageFolderResolver;
|
|
pub use package_json::PackageJsonCacheRc;
|
|
pub use package_json::PackageJsonResolver;
|
|
pub use package_json::PackageJsonResolverRc;
|
|
pub use package_json::PackageJsonThreadLocalCache;
|
|
pub use path::PathClean;
|
|
pub use path::UrlOrPath;
|
|
pub use path::UrlOrPathRef;
|
|
pub use resolution::parse_npm_pkg_name;
|
|
pub use resolution::resolve_specifier_into_node_modules;
|
|
pub use resolution::types_package_name;
|
|
pub use resolution::ConditionsFromResolutionMode;
|
|
pub use resolution::NodeResolution;
|
|
pub use resolution::NodeResolutionKind;
|
|
pub use resolution::NodeResolver;
|
|
pub use resolution::NodeResolverRc;
|
|
pub use resolution::ResolutionMode;
|
|
pub use resolution::DEFAULT_CONDITIONS;
|
|
pub use resolution::REQUIRE_CONDITIONS;
|