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

getQueryVariables is not typed #53

Open
TylerBreau opened this issue Jun 30, 2022 · 0 comments
Open

getQueryVariables is not typed #53

TylerBreau opened this issue Jun 30, 2022 · 0 comments
Milestone

Comments

@TylerBreau
Copy link
Contributor

Request.getQueryVariables is typed any. There is no current way for usages of @breautek/storm to define and have the typings be enforced.

Unfortunately fixing the typings is not super easy. The @type/express typings for express.Request.query originate from the types for the qs library.
There is some middlemen in the typings but it ultimately maps to qs' ParsedQs.

interface ParsedQs { [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[] }

During a discussion between @breautek and I in slack, it was decided that...

storm only supports what Record<string, string | string[]>

Fixing this issue would require...

  1. Adding a new generic to Request that extends/implements/defaults to Record<string, string | Array<string>>
  2. Updating the return type of getQueryVariables to the new generic. In order to satisfy typings, you will have to force retype this.$request.query by doing <NewGeneric><unknown> this.$request.query
  3. Handler's TGetRequest currently maps to the TBody. This either needs to be updated to map to the query variables generic, or a new generic needs to be added to Handler.
@breautek breautek added this to the 9.0.0 milestone Jun 13, 2024
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