Skip to content
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

Typescript warning in serialize-query-params for createEnumArrayParam (when following readme ) #269

Open
arnthors opened this issue Jun 26, 2023 · 0 comments

Comments

@arnthors
Copy link

The readme gives the following code example: const ColorArrayEnumParam = createEnumArrayParam<Color[]>(['red', 'green', 'blue']) but this raises the following typescript warning Type 'Color[]' does not satisfy the constraint 'string'.ts(2344)

This makes sense when looking at the Typescript declarations for createEnumArrayParam which is as follows: declare const createEnumArrayParam: <T extends string>(enumValues: T[])

This illustrates that only T is expected as a generic type parameter declaration while the expected function parameter is an array of T.

So I believe the solution here is update the Readme from:
const ColorArrayEnumParam = createEnumArrayParam<Color[]>(['red', 'green', 'blue'])
to:
const ColorArrayEnumParam = createEnumArrayParam<Color>(['red', 'green', 'blue'])

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

1 participant