Definitelytyped: Module '".../node_modules/@types/lodash"' has no exported member 'Cancelable'.

Created on 31 Aug 2020  路  6Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Greetings!

I work with a few Angular projects. One of them has a dependency on a library 'angular-tree-component', which depends on '@types/lodash'.

A few days ago, pull request 46971 was merged, generating version 4.14.161. As 'angular-tree-component' declares '^4.14.62' as the required version, the library was updated, generating the following error:

ERROR in node_modules/angular-tree-component/dist/components/tree-viewport.component.d.ts(3,10): error TS2305: Module '"MY_PATH/node_modules/@types/lodash"' has no exported member 'Cancelable'.

My question is: was it an implementation error from 'angular-tree-component' to use Cancelable as a return type, or should this interface be kept in '@types/lodash' for compatibility purposes?

Thank you!

Most helpful comment

Hey @Luis16287 !

For now, I'm fixing @types/lodash version at 4.14.160 in my project's package.json. At least it started building again.

All 6 comments

I have exactly the same problem. I am using angular-tree-component : 8.0.0 in a project, when compiling it gives me the following error:

node_modules / angular-tree-component / dist / components / tree-viewport.component.d.ts: 3:10 - error TS2305: Module '"MyPath / node_modules / @ types / lodash"' has no exported member 'Cancelable'.

What should I do?

I have the same doubt as @LAlves91

The configuration of my project is as follows:

  • Angular CLI: 8.0.0
  • Node: 10.13.0
  • npm: 6.4.1
  • rxjs: 6.4.0
  • typescript: 3.4.5
  • webpack: 4.39.2
  • @types/lodash": "~4.14.118
  • lodash": "4.17.12
  • angular-tree-component": "8.0.0 // for Angular 9 or higher you should switch to the @circlon/angular-tree-component

Hey @Luis16287 !

For now, I'm fixing @types/lodash version at 4.14.160 in my project's package.json. At least it started building again.

4.14.161 introduces a breaking change. Looks like the Cancellable interface has been removed and replaced with DebouncedFunc. Check this commit: https://github.com/DefinitelyTyped/DefinitelyTyped/commit/93d8f9d7102925e1a39852627465a44a0ff670cf

Thanks @miwels for pinpointing the change, that did the trick.

Here's an example change

Changed

debouncedMethod: ((x: any) => void) & Cancelable;

to

debouncedMethod: DebouncedFunc<(x: any) => void>;

And also the import to

import { DebouncedFunc, ...more.... } from "lodash";

Same error showed up here, rebuilding my project locally when I lost cache.

Somehow I got rid of it but now I have this:

node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax.
The command '/bin/sh -c tsc -p .' returned a non-zero code: 2

I'm running on Docker and nothing has changed in the repository.
On my yarn.lock files some deps do have

  dependencies:
    "@types/node" "*"

Could anyone help? Thanks!

@LAlves91

Sorry for the delay, for the particular case of the angular project using angular-tree-component, I got the following response

"This issue is due to @ types / lodash being a dependency in version 8 up to 8.2.0. This should have been fixed with 8.2 .1. I'm not sure what else was done and how risky / time-consuming the switch from 8.0.0 to 8.2.1 is. I checked and we used version 8.3.0 together with Angular 8.0.0 and version 8.4. 0 of the tree with Angular 8.2.0.
Do you want a 8.0.6 with this fix as well? One problem is that we can not publish to the old npm name. We would have to publish this under @ circlon / angular-tree-component. This probably would also mean republishing everything up to 8.5.6 under the new name so you don't need to switch the package names updating to another 8.x.x version.
Is this something that's wanted / needed? How many can not update the tree to a newer version?
"

So I tried the following configuration

  • Angular CLI: 8.0.0
  • Node: 10.13.0
  • npm: 6.4.1
  • rxjs: 6.4.0
  • typescript: 3.4.5
  • webpack: 4.39.2
  • lodash": "4.17.12
    with these changes
  • @types/lodash": "4.14.160
  • angular-tree-component": "8.3.0 // for Angular 9 or higher you should switch to the @circlon/angular-tree-component

And it has worked correctly for me

If you want to follow the thread is here (angular-tree-component#859)

Was this page helpful?
0 / 5 - 0 ratings