Skip to content

Commit 0efaddc

Browse files
committed
fix: the type definition of JSONQueryProperty and JSONQueryFunction
1 parent 82333d7 commit 0efaddc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const functions: FunctionBuildersMap = {
171171

172172
pick: (...properties: JSONQueryProperty[]) => {
173173
const getters = properties.map(
174-
([_get, ...path]) => [path[path.length - 1], functions.get(...(path as JSONPath))] as Getter
174+
([_get, ...path]) => [path[path.length - 1], functions.get(...path)] as Getter
175175
)
176176

177177
const _pick = (object: Record<string, unknown>, getters: Getter[]): unknown => {
@@ -294,7 +294,7 @@ export const functions: FunctionBuildersMap = {
294294
not: buildFunction((a: unknown) => !a),
295295

296296
exists: (queryGet: JSONQueryFunction) => {
297-
const parentPath = queryGet.slice(1) as JSONPath
297+
const parentPath = queryGet.slice(1)
298298
const key = parentPath.pop()
299299
const getter = functions.get(...parentPath)
300300

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export type JSONQueryFunction = [name: string, ...args: unknown[]]
1+
export type JSONQueryFunction = [name: string, ...args: JSONQuery[]]
22
export type JSONQueryObject = { [key: string]: JSONQuery }
33
export type JSONQueryPrimitive = string | number | boolean | null
44
export type JSONQuery = JSONQueryFunction | JSONQueryObject | JSONQueryPrimitive
55

66
export type JSONProperty = string
77
export type JSONPath = JSONProperty[]
8-
export type JSONQueryProperty = ['get', path?: string | JSONPath]
8+
export type JSONQueryProperty = ['get', ...path: JSONPath]
99
export type JSONQueryPipe = ['pipe', ...JSONQuery[]]
1010

1111
export interface JSONQueryOptions {

0 commit comments

Comments
 (0)