Add support for string union types in searchParams Record value #625
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Description
I am using
swagger-typescript-api
to automatically generate API functions, which are customized using an ejs template. The generated API request functions look like this:However, the
Record
type used insearchParams
does not supportstring
union types as values, leading to the following TypeScript error:As a result, I am forced to cast
params
usingas never
to bypass the error, which is not ideal.Proposed Solution
By adding
unknown
to the value type of theRecord
used insearchParams
, this TypeScript error can be resolved. This allows for better flexibility when dealing with union types, improving the overall developer experience.