Argument of type 'unknown' is not assignable to parameter of type 'Id<string>'.
The basic tutorials don't work with typescript. eg
https://docs.convex.dev/functions/query-functions#query-arguments-and-responses
when I try to make a query that takes params, in typescript, eg like this:
I get this error:
Argument of type 'unknown' is not assignable to parameter of type 'Id<string>'.
how do i pass params to a query in a way that compiles?Queries | Convex Developer Hub
Queries are the bread and butter of your backend API. They fetch data from the
6 Replies
This error is similar to the typescript error
Parameter 'id' implicitly has an 'any' type.
-- it means your function argument is missing a type annotation. You can add the annotation like this:
There are more examples in the typescript docs https://docs.convex.dev/typescript and the Typescript demo https://github.com/get-convex/convex-demos/tree/main/typescript
TypeScript | Convex Developer Hub
Move faster with end-to-end type safety.
GitHub
convex-demos/typescript at main · get-convex/convex-demos
Demo apps built on Convex. Contribute to get-convex/convex-demos development by creating an account on GitHub.
Also check out argument validators: https://docs.convex.dev/functions/args-validation#defining-validators
Argument Validation | Convex Developer Hub
Argument validators ensure that queries,
thanks! for now i've been typing the query params
With validators:
Yep the using with validators is quite nice because it gives you both argument validation and types.