Skip to content

Latest commit

 

History

History
21 lines (12 loc) · 1.12 KB

duplicate-packages.md

File metadata and controls

21 lines (12 loc) · 1.12 KB

duplicate-packages

Finding: a package is loaded more than once.

What it is

When two dependencies ask for incompatible versions of the same package, the package manager installs both, for example node_modules/a/node_modules/x@1 and node_modules/b/node_modules/x@2. The compiler loads, binds and checks each copy separately. Their types are not interchangeable, which also causes errors like "Type 'X' is not assignable to type 'X'".

How typescript-perf detects it

From the packageId the compiler prints in --explainFiles (with packageId 'x/index.d.ts@1.0.0'): the same package name at two or more different paths. Duplicates reported by @typescript/analyze-trace are added to the list. When a trace is available, the check time of all the copies is shown.

It is reported as Suggested: deduplicating changes node_modules and the lockfile, so typescript-perf never does it for you.

Fix

npm dedupe        # or: pnpm dedupe, yarn dedupe

If the versions are really incompatible, align the dependents (upgrade the one that pins the old version) or use your package manager's overrides / resolutions.