lodash/fp - How to augment typescript types from @types/lodash?

Viewed 355

I'm trying to change the typings of _.keys function in lodash/fp.

Original type looks like this: type LodashKeys = (object: any) => string[];

I've tried doing this:

// src/types/global.d.ts
import _ from 'lodash/fp';
declare module 'lodash/fp' {
  interface LodashKeysNew {
    <T>(object: T): (keyof T)[];
  }

  interface LoDashFp {
    keys: LodashKeysNew;
  }
}

But when I hover _.keys in VSCode it still shows the original typings.

enter image description here

I can Ctrl+Click the _.keys and I can see that it refers to my augmented type:

But it still doesn't work. Doesn't affect typechecking, still uses the original types. I have tried a lot of different things and I can't seem to make it work. I successfully augmented several other libraries, but lodash is somehow weird.

0 Answers
Related