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
Environment information
Details
Rule name
correctness/noUnresolvedImportsPlayground link
https://github.com/AlbinoGeek/biome-types-stub-shadows-own-typings
node_modules/legacy-pkgis an ordinary package shipping its own types, with noexportsmap:{ "main": "libs/legacy-pkg.js", "typings": "typings/legacy-pkg.d.ts" }node_modules/@types/legacy-pkgis the stub DefinitelyTyped publishes for packages thatship their own types — no
index.d.ts, andmainis 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-pkgThe resolver appears to prefer the
@typesentry, read its emptymainas a directory,look for an
indexinside, and stop — rather than falling back to the package's owntypings.tscresolves the same tree without complaint.Real-world instance:
lz-stringwith@types/lz-string@1.5.0installed. The stub isdeprecated 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
@typespackage with an emptymainand noindex.d.tscarries no declarations andshould not shadow the real package.
Code of Conduct