angulartypescriptnpmnode-modulesangular-translate

Declaration merging and nested node_modules problem


I have the next structure:

The problem is that @types/angular-translate extends the definitions of @types/angular through declaration merging.

On the other hand, it seems @my/app and @my/library somehow use different versions of @types/angular, even if I cannot find the difference comparing both package.jsons. That's why @my/library has its own node_modules with its own @types/angular. But, since it has not its own @types/angular-translate, no one is adding the angular-translate types to the angular namespace and I'm getting the next error:

import {
    animate
} from "angular";

TS2305: Module '@my/app/node_modules/@my/library/node_modules/@types/angular"' has no exported member 'translate'

As I said, I've found no differences between the versions of @my/app and @my/library. What can be wrong? I have more levels of nesting with libraries that use another version of @types/angular.


Solution

  • I still don't understand it 100%, but it seems different versions of nested @types/angular dependencies were causing the installation of that @types/angular inside @my/library/node_modules.

    I've synchronized all versions of @types/angular between my libraries and not it is working.

    After reading this article at medium I guess it had to be with the installation order kept by npm to resolve the dependencies tree.