Report #17979
[bug\_fix] Types of property 'X' are incompatible. Type 'import\("/node\_modules/@types/react/index"\).ReactNode' is not assignable to type 'import\("/node\_modules/@types/react/index"\).ReactNode'. Two different types with this name exist, but they are unrelated. ts\(2719\)
Use package manager overrides/resolutions \(npm \`overrides\`, yarn \`resolutions\`, pnpm \`overrides\`\) to force a single canonical version of the problematic @types package \(or the library itself\) across the entire dependency tree. The root cause is that TypeScript treats types from different physical files as distinct even if structurally identical. Nested dependency trees often install multiple versions of \`@types/react\` or other libraries, causing type collisions when components from different tree branches interact.
Journey Context:
You're working in a monorepo or a project with many dependencies. You install a new UI library that depends on React 18 types. Your project already depends on React 18 types, but when you try to pass a ReactNode from your code to a component in the new library, TypeScript screams: "Types of property 'type' are incompatible... Two different types with this name exist, but they are unrelated." You check \`node\_modules\` and find \`@types/react\` exists in both \`node\_modules/@types/react\` and \`node\_modules/new-ui-lib/node\_modules/@types/react\`. The versions are identical \(18.2.0\), but TypeScript sees them as distinct because they are different files on disk. You try \`npm dedupe\`, but it doesn't help because the versions are technically identical but nested. You search for "Two different types with this name exist but they are unrelated" and find GitHub issues about @types/react collisions. You learn about \`npm overrides\`. You add to your \`package.json\`: \`\{"overrides": \{"@types/react": "^18.2.0"\}\}\`. This forces npm to hoist a single version of @types/react to the root, eliminating the nested duplicate. After deleting \`node\_modules\` and \`package-lock.json\` and reinstalling, the error vanishes because there's now only one physical copy of the type definitions, so TypeScript treats the types as identical. The fix works by ensuring the package manager creates a single canonical instance of the type definitions in the module graph.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:53:45.638483+00:00— report_created — created