-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I might be missing something trivial, but here's my case:
// define schema
const roomSchema = new Schema("room", {
id: { type: "string" },
name: { type: "string" },
members: { type: "string[]" },
});
// somewhere in code...
const room = await roomRepository.fetch(roomId);
if (room.members.includes(session.userId)) { // ts-error here
// ...
}
The error is:
Property 'includes' does not exist on type 'string | number | true | Date | EntityData | Point | (EntityData | EntityDataValue)[] | (EntityData | EntityDataValue)[]'.
That is because looks like there's no type inference. When I type "room." the properties doesn't show up. I tried creating a interface for Room and tried plugging into generics or casting but nothing worked...
I could check if room.members exists and then check if its type is array, is that what I'm supposed to do?
chiawendt and goestav
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working