NPM.TypesResolution (NPM v0.6.0)

Copy Markdown View Source

Resolves DefinitelyTyped @types/ packages for TypeScript consumers.

Maps package names to their corresponding @types/ package names and checks if type definitions are needed or already provided.

Summary

Functions

Checks if a package bundles its own types (has a types or typings field).

Lists all @types/ packages in the lockfile.

Finds packages that need @types/ definitions.

Maps installed @types/ packages back to the packages they provide types for.

Returns the @types/ package name for a given package.

Functions

has_bundled_types?(pkg_data)

@spec has_bundled_types?(map()) :: boolean()

Checks if a package bundles its own types (has a types or typings field).

installed_types(lockfile)

@spec installed_types(map()) :: [String.t()]

Lists all @types/ packages in the lockfile.

missing_types(pkg_data, lockfile, node_modules_dir \\ "node_modules")

@spec missing_types(map(), map(), String.t()) :: [String.t()]

Finds packages that need @types/ definitions.

Returns packages that don't bundle types and whose @types/ package is not in the lockfile.

types_map(lockfile)

@spec types_map(map()) :: %{required(String.t()) => String.t()}

Maps installed @types/ packages back to the packages they provide types for.

types_package(name)

@spec types_package(String.t()) :: String.t()

Returns the @types/ package name for a given package.