How to represent objects in args (v.object)

Hi, I know that I can use args: { lat: v.number(), lng: v.number() }, for a mutation (didn't check it for a query) and it would work fine. But I'm curious why I can't define the args like that: args: { coord: { lat: v.number(), lng: v.number() } }, because then I get this error on mutation:
TS2769: No overload matches this call.
Overload 1 of 2,
(func: ValidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIndexes: {}; }; }>, PropertyValidators, Promise<...>>): RegisteredMutation<...>
, gave the following error.
Object literal may only specify known properties, and lat does not exist in type Validator<any, any, any>
Overload 2 of 2,
(func: UnvalidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIndexes: {}; }; }>, [args: ...], Promise<...>>): RegisteredMutation<...>
, gave the following error.
Object literal may only specify known properties, and args does not exist in type
UnvalidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIn...
TS2769: No overload matches this call.
Overload 1 of 2,
(func: ValidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIndexes: {}; }; }>, PropertyValidators, Promise<...>>): RegisteredMutation<...>
, gave the following error.
Object literal may only specify known properties, and lat does not exist in type Validator<any, any, any>
Overload 2 of 2,
(func: UnvalidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIndexes: {}; }; }>, [args: ...], Promise<...>>): RegisteredMutation<...>
, gave the following error.
Object literal may only specify known properties, and args does not exist in type
UnvalidatedFunction<GenericMutationCtx<{ search: { document: { _id: Id<"search">; _creationTime: number; admin1: string; admin2: string; coord: { lat: number; lon: number; }; country: string; id: number; name: string; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { ...; }; searchIndexes: { ...; }; vectorIn...
^ You get the idea
2 Replies
lee
lee•12mo ago
the syntax for that is args: { coord: v.object({ lat: v.number(), lng: v.number() }) },

Did you find this page helpful?