0

I use the graphql-mesh package in my project. This library has the following type definition:

declare global {
  interface ObjectConstructor {
    keys<T>(obj: T): Array<keyof T>;
  }
}

This type definition breaks my build. I have errors like that:

Argument of type 'string | number | symbol' is not assignable to parameter of type 'string'.
  Type 'number' is not assignable to type 'string'.

278       expect(bar.get(Object.keys(given.foo)[0]))

How can I fix it? Is there an option to override this type in my project? Or can TypeScript compiler ignore this type definition?

Mike
  • 613
  • 1
  • 10
  • 20
  • 2
    I'd be inclined to fork the project, remove that extension, and do a PR. [`Object.keys`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) has been standard for years now, and it returns `Array` (`string[]`), not `Array`. – T.J. Crowder Mar 15 '21 at 16:46
  • If you're looking to use the project [graphql-mesh](https://graphql-mesh.com/) then you have the wrong npm package. The proper ones are much more actively maintained. See the installation instructions: https://github.com/Urigo/graphql-mesh – Thomas Mar 15 '21 at 16:50

0 Answers0