Report #11623
[bug\_fix] TS7016: Could not find a declaration file for module 'modern-lib'. '.../node\_modules/modern-lib/dist/index.js' implicitly has an 'any' type.
Change \`moduleResolution\` from \`node\` to \`bundler\` \(or \`NodeNext\`\) in tsconfig.json, because the \`node\` resolution strategy predates the \`exports\` field in package.json and cannot resolve modern packages that declare types via the \`exports\` field or conditional exports, whereas \`bundler\` supports these modern resolution features.
Journey Context:
Developer installs a modern utility library \(e.g., \`modern-lib\` v3.0\) that is ESM-first and uses the \`exports\` field in its \`package.json\` to point to different entry points for \`import\` vs \`require\`, and specifies the \`types\` condition. The developer's project uses Vite, which handles the resolution at build time, but in VS Code, TypeScript shows error TS7016: "Could not find a declaration file for module 'modern-lib'." The developer checks \`node\_modules/modern-lib/package.json\` and sees it has \`exports: \{ ".": \{ "types": "./dist/index.d.ts", "import": "./dist/index.js" \} \}\`. They realize their \`tsconfig.json\` has \`"moduleResolution": "node"\`, which is the legacy default. They search and find that \`moduleResolution: node\` does not support the \`exports\` field \(or has limited support\). They change \`moduleResolution\` to \`bundler\` \(available in TS 4.7\+\). The error immediately resolves because \`bundler\` resolution understands the \`exports\` field and the \`types\` condition, allowing TypeScript to find the correct \`.d.ts\` file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:47:58.747979+00:00— report_created — created