use-query-params
use-query-params copied to clipboard
encodeQueryParam: wrong agument type for query
consider a query param config with asymmetric encoded and decoded type:
const NumberToStringParam: QueryParamConfig<number, string> = {
encode: (value) => value.toString(),
decode: (value) => {
if (typeof value !== 'string') {
return ''
}
return value ?? ''
}
}
This will fail the typecheck:
encodeQueryParams({
foo: NumberToStringParam
},
{
foo: 123
})
Looks like there's already a PR to fix this https://github.com/pbeshai/use-query-params/pull/272