#TIL 15 - Fix Duplicate identifier 'LibraryManagedAttributes' | ProductsWay

#TIL 15 - Fix Duplicate identifier 'LibraryManagedAttributes'

Aug 21, 2021 · Dung Huynh

What

Fix the TypeScript "Duplicate identifier 'LibraryManagedAttributes'" error in React projects.

Why

When two packages depend on compatible ranges of @types/react, Yarn can still install duplicate versions and TypeScript sees conflicting global declarations. yarn-deduplicate can select one version that satisfies both ranges. If the ranges are incompatible, align the dependencies or add a resolution before deduplicating.

How

npx yarn-deduplicate yarn.lock

Then reinstall dependencies:

yarn install