Skip to content

encodeQueryParam: wrong agument type for query #297

Description

@prayogoa

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
})

TS Playground link

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions