Typescript warning in serialize-query-params for createEnumArrayParam (when following readme )
arnthors opened this issue · comments
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'])