RJ
RJ2y ago

Type error during 0.17 upgrade

I'm currently upgrading to 0.17, and am seeing the following error whenever I try to alter my Convex functions to use the new reference strategy:
typescript: Argument of type '{ default: FunctionReference<"query", "internal", {}, { _id: Id<"migrations">; _creationTime: number; number: number; }[]>; }' is not assignable to parameter of type 'FunctionReference<"query", "internal" | "public">'.
Type '{ default: FunctionReference<"query", "internal", {}, { _id: Id<"migrations">; _creationTime: number; number: number; }[]>; }' is missing the following properties from type 'FunctionReference<"query", "internal" | "public">': _type, _visibility, _args, _returnType [2345]
typescript: Argument of type '{ default: FunctionReference<"query", "internal", {}, { _id: Id<"migrations">; _creationTime: number; number: number; }[]>; }' is not assignable to parameter of type 'FunctionReference<"query", "internal" | "public">'.
Type '{ default: FunctionReference<"query", "internal", {}, { _id: Id<"migrations">; _creationTime: number; number: number; }[]>; }' is missing the following properties from type 'FunctionReference<"query", "internal" | "public">': _type, _visibility, _args, _returnType [2345]
Happy to provide more info as helpful, but any clue what might be going on?
4 Replies
sshader
sshader2y ago
I think you maybe had a "path/to/foo" that was changed to api.path.to.foo instead of api.path.to.foo.default?
RJ
RJOP2y ago
Ohh, so now I need to append "default" in the case where the function is the default export of the file in that path?
sshader
sshader2y ago
Yep exactly. Definitely a little awkward, so we rewrote a bunch of our examples to use named exports instead (e.g. api.messages.list instead of api.listMessages.default). I think we've looked in to avoiding the .default, but it gets tricky with support jump to definition in vscode.
RJ
RJOP2y ago
It definitely makes sense that you'd need some way to disambiguate, since you lost the / vs : distinction I don't have any good ideas either, but it's not too big of a deal either IMO Thanks @sshader!

Did you find this page helpful?