Skip to content

Commit ad7b95d

Browse files
committed
fix(ts): properly infer nested paths from row type
1 parent 5e842af commit ad7b95d

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

bun.lockb

0 Bytes
Binary file not shown.

docs/filter-match-modes/object-match.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ This example returns items where at least one order has a total greater than 200
205205
The `applyAtRoot` option allows you to apply the filter to the root object instead of a nested property:
206206

207207
```ts twoslash
208+
// @errors: 2322
208209
import { query } from '@chronicstone/array-query'
209210

210211
const data = [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@antfu/eslint-config": "^2.22.0-beta.2",
5353
"@antfu/ni": "^0.21.12",
5454
"@antfu/utils": "^0.7.10",
55-
"@chronicstone/array-query": "0.2.2",
55+
"@chronicstone/array-query": "0.2.3",
5656
"@faker-js/faker": "^8.4.1",
5757
"@shikijs/vitepress-twoslash": "^1.10.3",
5858
"@types/node": "^20.14.10",

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export type NestedPaths<T> = T extends Array<infer U>
77
? {
88
[K in keyof T & (string | number)]: K extends string
99
? `${K}` | `${K}.${NestedPaths<T[K]>}`
10-
: string;
10+
: never;
1111
}[keyof T & (string | number)]
12-
: string
12+
: never
1313

1414
export type NestedPathsForType<T, P> = T extends Array<infer U>
1515
? NestedPathsForType<U, P>
@@ -99,7 +99,7 @@ export interface QueryParams<
9999
PrimitivePath extends string = NestedPathsForType<T, string | number | null | boolean | undefined>,
100100
> {
101101
sort?: SortOption<PrimitivePath> | Array<SortOption<PrimitivePath>>
102-
search?: SearchOptions<PrimitivePath>
102+
search?: SearchOptions<Paths>
103103
filter?: FilterOptions<Paths>
104104
limit?: number
105105
page?: number

0 commit comments

Comments
 (0)