Closed vieruuuu closed 2 months ago
It's Typescript struggling to infer the type of the argument even though you're assigning a string to it. I've seen it happen outside of lib code as well, I would guess it might be related to some tsconfig
options. Regardless, the fix is just to add the type to the argument:
const foo = createQueryKeys('foo', {
bar: (key: string = "test") => ({
queryKey: [key],
queryFn: () => Promise.resolve(true)
})
})
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYygUwIYzQRQK5pQCeA0mkQM4A0cAKkWGgCYCqFuBxA8mDMBADsKcAL5wAZlAgg4AcgACAGzwBrNCGgZFaCgHoAjpyIBaNSfEZkMaEVkAoO8kEV44iBDgBeFOiwdCpOQUABSybhCyNAh2cLFwAEYYUABccMFmXnAARNguWQCUXgB8adFxcLq65QB6APwx5XGGAWREqQDaZgC6VA2NcM3EAGICqcGFniUAClIgwOwAdOgUEIoAbmjBMFAE+X2ieyJ7dkA