SolvedDefinitelyTyped [lodash] Type 'T' does not satisfy the constraint 'object'.

If you know how to fix the issue, make a pull request instead.

I just did an update of my npm packages and started getting an error in my builds:

ERROR in [at-loader] ./node_modules/@types/lodash/index.d.ts:12651:53
Type 'T' does not satisfy the constraint 'object'.

This initially confused me, as I'm not including lodash in my project. After some digging, it appears that TypeDoc recently updated their type dependencies (TypeStrong/typedoc@afd6b60#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R36). I would put in an issue there, but this seems more to be an issue specific to the types.

What it's complaining about, specifically seems to be this:

    interface LoDashStatic {
         * Checks if value is classified as a WeakSet object.
         * @param value The value to check.
         * @returns Returns true if value is correctly classified, else false.
        isWeakSet<T>(value?: any): value is WeakSet<T>;

In particular, "isWeakSet(value?: any): value is WeakSet<T>;"
If I alter T to extend object, the error goes away, but wanted to make sure that's the appropriate fix.

28 Answers

✔️Accepted Answer


Ok, so your third party probably needs to update their dependency. You might be able to control the version anyway by running npm install -S @types/lodash@latest (or similar in yarn). See if that fixes it.

Other Answers:

Ok, yeah, looks like that built successfully

I had this error with @types/lodash 4.14.78 upon upgrading to typescript 2.7.2

found this thread, updated @types/lodash to 4.14.108, and the error is gone! seems like this should be closed to me

This issue is blocking update to angular 6. Angular 6 requires typescript version >= 2.7.2 .
Is it possible to update lodash? I see people suggesting a change, could those changes be accepted?

More Issues: