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

use const type Parameter for QueryBuilder.only() to not lose typing #2545

Closed
thunfisch987 opened this issue Feb 7, 2024 · 0 comments · Fixed by #2546
Closed

use const type Parameter for QueryBuilder.only() to not lose typing #2545

thunfisch987 opened this issue Feb 7, 2024 · 0 comments · Fixed by #2546
Labels
enhancement New feature or request

Comments

@thunfisch987
Copy link
Contributor

thunfisch987 commented Feb 7, 2024

Is your feature request related to a problem? Please describe

When you're building a query and you use the .only() method you lose the typing because typescript only infers Pick<ParsedContent, string> and not Pick<ParsedContent, "whatever-you-specified">.
I had this problem when using queryContent("...").only(["...","..."]).findSurround()

Describe the solution you'd like

The solution would be using <const K extends keyof T> instead of <K extends keyof T>
The const type parameter was introduced with Typescript 5.0

Describe alternatives you've considered

Letting it stay this way

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant