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

Allow defining type for getQuery() function via generic #22262

Closed
4 tasks done
DeepKumbhare85 opened this issue Jul 21, 2023 · 1 comment
Closed
4 tasks done

Allow defining type for getQuery() function via generic #22262

DeepKumbhare85 opened this issue Jul 21, 2023 · 1 comment

Comments

@DeepKumbhare85
Copy link

Describe the feature

In server API When we use getQuery() function to parse params from query, it provides type as QueryValue | QueryValue[].
It would be great if we could provide types to this params.

check below code snippet.

export default defineEventHandler((event) => {
    const queries = getQuery(event)
	const searchQuery = queries.q
}

here the type of searchQuery is QueryValue | QueryValue[], but I want type to be string | undefined.It would be great If I could narrow down type to string | undefined.currently I am providing types using typeof for every param.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@danielroe
Copy link
Member

Agreed, this would be good. Would you open a feature request to https://github.com/unjs/ufo?

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants