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 #155

Closed
1 task
DeepKumbhare85 opened this issue Jul 24, 2023 · 1 comment
Closed
1 task

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

DeepKumbhare85 opened this issue Jul 24, 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.

reference: nuxt/nuxt#22262

Additional information

  • Would you be willing to help implement this feature?
@pi0
Copy link
Member

pi0 commented Jul 28, 2023

Hi. It will be possible with #131 (also see unjs/h3#417)

@pi0 pi0 closed this as completed Jul 28, 2023
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