Report #71246
[bug\_fix] Conflicting definitions for 'setTimeout' \(or 'console', 'Buffer'\) between @types/node and lib.dom.d.ts
Explicitly control which type definitions are included using the \`types\` array in tsconfig.json. For a Node.js-only project, set \`"types": \["node"\]\` to exclude DOM lib types. For a browser-only project, omit @types/node or exclude it. For shared code, use project references or separate tsconfig files for Node and browser contexts.
Journey Context:
You are building a full-stack application with a shared \`types\` package used by both the Node backend and React frontend. In your shared tsconfig, you have \`"lib": \["ES2020", "DOM"\]\`. You also have \`@types/node\` installed because some shared utilities run on the server. Suddenly, TypeScript reports errors about duplicate identifiers: \`setTimeout\` is defined in both \`lib.dom.d.ts\` and \`@types/node/index.d.ts\`. Similarly for \`console\`, \`Buffer\`, and \`process\`. You try adding \`skipLibCheck: true\`, which suppresses the error but doesn't fix the underlying type confusion. You realize that \`@types/node\` and \`lib.dom\` both declare global environment types that conflict. The root cause is that TypeScript is including both the DOM library \(for browser\) and Node.js types \(for server\) in the same compilation. The solution is to use the \`types\` compiler option to explicitly whitelist only the types needed for the specific environment, or to use separate tsconfig.json files for Node and browser code with project references.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:09:38.490840+00:00— report_created — created