Skip to content

encodeQueryParam: wrong agument type for query #297

Open
@prayogoa

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

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