Skip to content

💅 noUnresolvedImports: a deprecated @types stub shadows a package's own typings #11881

Description

@AlbinoGeek

Environment information

Details
CLI:
  Version:                      2.5.14

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:           npm
  JS_RUNTIME_NAME:              bun

Rule name

correctness/noUnresolvedImports

Playground link

https://github.com/AlbinoGeek/biome-types-stub-shadows-own-typings

import { greet } from 'legacy-pkg'
× The import specifier legacy-pkg cannot be resolved: found directory without index

node_modules/legacy-pkg is an ordinary package shipping its own types, with no
exports map:

{ "main": "libs/legacy-pkg.js", "typings": "typings/legacy-pkg.d.ts" }

node_modules/@types/legacy-pkg is the stub DefinitelyTyped publishes for packages that
ship their own types — no index.d.ts, and main is the empty string:

{
  "main": "",
  "deprecated": "This is a stub types definition. legacy-pkg provides its own type definitions, so you do not need this installed."
}
@types/legacy-pkg Result
absent resolves
present cannot be resolved

The resolver appears to prefer the @types entry, read its empty main as a directory,
look for an index inside, and stop — rather than falling back to the package's own
typings. tsc resolves the same tree without complaint.

Real-world instance: lz-string with @types/lz-string@1.5.0 installed. The stub is
deprecated and should not be installed, but it is a common leftover, and npm does not
remove it automatically.

Expected result

The import resolves via the package's own typings, as it does when the stub is absent.
A @types package with an empty main and no index.d.ts carries no declarations and
should not shadow the real package.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Type-InferenceArea: type inferenceL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions