Skip to content

TS incompatibility with [email protected] stringify #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
effectiveduck opened this issue Oct 1, 2020 · 3 comments
Closed

TS incompatibility with [email protected] stringify #129

effectiveduck opened this issue Oct 1, 2020 · 3 comments

Comments

@effectiveduck
Copy link

Code:

const eq = encodeQueryParams(
    { x: StringParam },
    { x: "true" }
);
const y = stringify(eq);

Error:

Argument of type 'Partial<EncodedValueMap<{ x: QueryParamConfig<string | null | undefined, string | null | undefined>; }>>' is not assignable to parameter of type 'Record<string, string | number | boolean | Stringifiable[] | null | undefined>'.
  Property 'x' is incompatible with index signature.
    Type 'string | (string | null)[] | null | undefined' is not assignable to type 'string | number | boolean | Stringifiable[] | null | undefined'.
      Type '(string | null)[]' is not assignable to type 'string | number | boolean | Stringifiable[] | null | undefined'.
        Type '(string | null)[]' is not assignable to type 'Stringifiable[]'.
          Type 'string | null' is not assignable to type 'Stringifiable'.
            Type 'null' is not assignable to type 'Stringifiable'.

Initially I thought this was an error with how ArrayParams we're handled but it seems to affect every param type I've tried, also not sure if this is an issue related to this library or query-string but this made most sense to me.

[email protected] release

@pbeshai
Copy link
Owner

pbeshai commented Oct 1, 2020

Thanks for bringing this up, it looks like perhaps their new types are wrong. I'd suggest using an older version until they/we can fix the issue. I'll make an issue on their repo to figure it out.

Example:

> const qs = require('query-string')
undefined
> qs.parse('?foo&foo=1&foo&foo=test&foo=&foo')
[Object: null prototype] { foo: [ null, '1', null, 'test', '', null ] }
> qs.stringify({ foo: [null, '1', null, 'test', '', null] })
'foo&foo=1&foo&foo=test&foo=&foo'

@pbeshai
Copy link
Owner

pbeshai commented Oct 1, 2020

Follow along here sindresorhus/query-string#280

@pbeshai
Copy link
Owner

pbeshai commented Oct 2, 2020

Should be fixed in their next release

@pbeshai pbeshai closed this as completed Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants