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

fix(types): add const type parameter for .only() and .without() #2573

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/runtime/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ export interface QueryBuilder<T = ParsedContentMeta> {
/**
* Select a subset of fields
*/
only<K extends keyof T>(keys: K): QueryBuilder<Pick<T, K>>
only<K extends (keyof T)[]>(keys: K): QueryBuilder<Pick<T, K[number]>>
only<const K extends keyof T>(keys: K): QueryBuilder<Pick<T, K>>
only<const K extends (keyof T)[]>(keys: K): QueryBuilder<Pick<T, K[number]>>

/**
* Remove a subset of fields
*/
without<K extends keyof T | string>(keys: K): QueryBuilder<Omit<T, K>>
without<K extends (keyof T | string)[]>(keys: K): QueryBuilder<Omit<T, K[number]>>
without<const K extends keyof T | string>(keys: K): QueryBuilder<Omit<T, K>>
without<const K extends (keyof T | string)[]>(keys: K): QueryBuilder<Omit<T, K[number]>>

/**
* Sort results
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/types/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ export interface ContentQueryBuilder<T = ParsedContentMeta, Y = {}> {
/**
* Remove a subset of fields
*/
without<K extends keyof T | string>(keys: K): ContentQueryBuilder<Omit<T, K>, Y>
without<K extends (keyof T | string)[]>(keys: K): ContentQueryBuilder<Omit<T, K[number]>, Y>
without<const K extends keyof T | string>(keys: K): ContentQueryBuilder<Omit<T, K>, Y>
without<const K extends (keyof T | string)[]>(keys: K): ContentQueryBuilder<Omit<T, K[number]>, Y>

/**
* Filter results
Expand Down