lukemorales / query-key-factory

A library for creating typesafe standardized query keys, useful for cache management in @tanstack/query
https://www.npmjs.com/package/@lukemorales/query-key-factory
MIT License
1.16k stars 32 forks source link

Allow to use bigint in queryKey #56

Closed mc-petry closed 1 year ago

mc-petry commented 1 year ago

Actual:

createQueryKeys('users', {
  byId: (id: bigint) => ({
    queryKey: [id],
    queryFn: () => getUser({ id }),
  }),
})

We got an error: Type '[bigint]' is not assignable to type 'KeyTuple'.

Expected result: no error This must be allowed case since we can override queryKeyHashFn.

mc-petry commented 1 year ago

One way is to allow

type ValidValue = string | number | boolean | object | bigint;

but ValidValue in a real life can be any

I believe that we need to use global module augmentation here.

lukemorales commented 1 year ago

@mc-petry sorry for the long waiting, but v1.3.0 has been released and bigInt is now accepted as a valid value