Array of enums wrong type

Hello!

I'm trying to migrate a column from enum to an array of enums, like this:

// old type, 
role: userRoles("role").default("STUDENT").notNull(),
roles: userRoles("roles").array().$type<UserRole[]>().notNull(),


but when I try to insert any data, I get this type error:

roles: [] as UserRole[],
Type '("UNKNOWN" | "STUDENT" | "TEACHER" | "SUPERUSER" | "ROOT")[]' is not assignable to type '"UNKNOWN" | "STUDENT" | "TEACHER" | "SUPERUSER" | "ROOT" | undefined'.

How does one do it?
Was this page helpful?