Environment information
CLI:
Version: 2.4.9
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
JS_RUNTIME_VERSION: v24.11.1
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: pnpm/10.18.2
What happened?
noUnresolvedImports reports false positives for named exports from packages whose @types definitions use export = Namespace (CJS-style namespace exports). This affects widely used packages including react and lodash.
Example error:
app.tsx:1:10 lint/correctness/noUnresolvedImports
× The module react has no export named useState.
> 1 │ import { useState } from "react";
│ ^^^^^^^^
Root cause
When @types/react is installed, Biome prefers reading @types/react/index.d.ts over react/index.js for export resolution (likely due to PR #9267 which "Added preference for `types`/`typings` over `main` in package.json resolution").
@types/react/index.d.ts uses export = React — TypeScript's CJS interop syntax for namespaced exports. Biome cannot resolve individual named imports (useState, useCallback, etc.) from this pattern.
Removing @types/react from node_modules eliminates all false positives. Restoring it brings them back.
The same issue affects @types/lodash (which also uses export =).
Minimal reproduction
mkdir repro && cd repro
pnpm init
pnpm add react @types/react @biomejs/biome
cat > biome.json << 'EOF'
{ "linter": { "enabled": true, "domains": { "project": "all" } } }
EOF
echo 'import { useState } from "react"; export const x = useState;' > app.tsx
npx biome check app.tsx # ERROR: The module react has no export named useState.
pnpm remove @types/react
npx biome check app.tsx # No error
Expected result
noUnresolvedImports should correctly resolve named exports from the export = React pattern in .d.ts files, or fall back to the runtime module when the type declarations use this pattern.
Environment information
What happened?
noUnresolvedImportsreports false positives for named exports from packages whose@typesdefinitions useexport = Namespace(CJS-style namespace exports). This affects widely used packages includingreactandlodash.Example error:
Root cause
When
@types/reactis installed, Biome prefers reading@types/react/index.d.tsoverreact/index.jsfor export resolution (likely due to PR #9267 which "Added preference for `types`/`typings` over `main` in package.json resolution").@types/react/index.d.tsusesexport = React— TypeScript's CJS interop syntax for namespaced exports. Biome cannot resolve individual named imports (useState,useCallback, etc.) from this pattern.Removing
@types/reactfromnode_moduleseliminates all false positives. Restoring it brings them back.The same issue affects
@types/lodash(which also usesexport =).Minimal reproduction
Expected result
noUnresolvedImportsshould correctly resolve named exports from theexport = Reactpattern in.d.tsfiles, or fall back to the runtime module when the type declarations use this pattern.