Solved: error TS2428: All declarations of ‘WeakMap’ must have identical type parameters.

I was upgrading an angularJS application today and kept hitting the error: All declarations of ‘WeakMap’ must have identical type parameters.

ERROR in node_modules/typescript/lib/lib.es2015.collection.d.ts(45,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/typescript/lib/lib.es2015.iterable.d.ts(157,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts(133,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
typings/lodash/lodash.d.ts(20808,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.

I tried removing lodash but that didn’t work.

npm uninstall lodash --save
npm uninstall @types/lodash --save-dev

After much head scratching I spotted a rogue typings folder. Deleting that folder (and re-installing lodash) fixed the bug.

npm install lodash --save
npm install @types/lodash --save-dev

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.