Weird type error when searching by Index

I get this error when trying to filter by an index, i created it in my schema too. Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345) I ahve attached image of the query.
No description
No description
9 Replies
rishsane
rishsane2w ago
never type?
🐐GoatGuy🐐
🐐GoatGuy🐐OP2w ago
How can the parameter be never type though?
rishsane
rishsane2w ago
Yup there is never type in typescript bro It's kind of special thing
🐐GoatGuy🐐
🐐GoatGuy🐐OP2w ago
hmm i dont get it though, i created the index and ffollowed the docs, got no clue why it's giving me that linter error
sshader
sshader2w ago
Try giving ctx a type annotation with MutaitonCtx from _generated/server? (https://labs.convex.dev/auth/advanced#writing-additional-data-during-authentication) TS needs the type annotation to know about all the tables defined in your schema (not just the ones defined in the auth schema)
Advanced: Details - Convex Auth
Authentication library for your Convex backend
rishsane
rishsane2w ago
Do you know what is never type?
🐐GoatGuy🐐
🐐GoatGuy🐐OP2w ago
I assume it means it never returns something?
ballingt
ballingt7d ago
@🐐GoatGuy🐐 yeah see Sarah's comment, there's no way that this callback function can know about all your other tables, it only knows about those that come with Convex Auth unless you use MutationCtx explicitly When you write normal mutations etc. you use the mutation() wrapper imported from ../convex/_generated/server which imports from your schema. But the convexAuth() function doens't know about your schema, it's imported from the Convex Auth library.
rishsane
rishsane6d ago
Right. But there are some special cases.
function fail(): never {
throw new Error("This function never returns!");
}

const result = fail(); // Type of `result` is `never`
function fail(): never {
throw new Error("This function never returns!");
}

const result = fail(); // Type of `result` is `never`
We can't console.log(result)

Did you find this page helpful?