nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 627 forks source link

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

Closed thunfisch987 closed 9 months ago

thunfisch987 commented 9 months ago

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