Text Enum Typing

I'm getting a type error that I don't understand
This will throw an error
Type 'string[]' is not assignable to type 'readonly [string, ...string[]] | [string, ...string[]] | undefined'.
Type 'string[]' is not assignable to type '[string, ...string[]]'.
Source provides no match for required element at position 0 in target.ts(2322)
export const AwxRFIStatus = {
ACTION_REQURED: "ACTION_REQUIRED",
ANSWERED: "ANSWERED",
CLOSED: "CLOSED",
};

export const awsOrganizationStateTable = pgTable("awx_organization_state", {
organizationId: text("organization_id").notNull().primaryKey(),
awsRFIStatus: varchar("aws_kyc_account_status", {
length: 256,
enum: Object.values(AwxRFIStatus),
}).notNull(),
This will throw an error
Type 'string[]' is not assignable to type 'readonly [string, ...string[]] | [string, ...string[]] | undefined'.
Type 'string[]' is not assignable to type '[string, ...string[]]'.
Source provides no match for required element at position 0 in target.ts(2322)
export const AwxRFIStatus = {
ACTION_REQURED: "ACTION_REQUIRED",
ANSWERED: "ANSWERED",
CLOSED: "CLOSED",
};

export const awsOrganizationStateTable = pgTable("awx_organization_state", {
organizationId: text("organization_id").notNull().primaryKey(),
awsRFIStatus: varchar("aws_kyc_account_status", {
length: 256,
enum: Object.values(AwxRFIStatus),
}).notNull(),
Was able to resolve by casting but doesn't make sense to me
export const AwxRFIStatus = {
ACTION_REQURED: "ACTION_REQUIRED",
ANSWERED: "ANSWERED",
CLOSED: "CLOSED",
};

export const awsOrganizationStateTable = pgTable("awx_organization_state", {
organizationId: text("organization_id").notNull().primaryKey(),
awsRFIStatus: varchar("aws_kyc_account_status", {
length: 256,
enum: Object.values(AwxRFIStatus) as [string, ...string[]],
}).notNull(),
export const AwxRFIStatus = {
ACTION_REQURED: "ACTION_REQUIRED",
ANSWERED: "ANSWERED",
CLOSED: "CLOSED",
};

export const awsOrganizationStateTable = pgTable("awx_organization_state", {
organizationId: text("organization_id").notNull().primaryKey(),
awsRFIStatus: varchar("aws_kyc_account_status", {
length: 256,
enum: Object.values(AwxRFIStatus) as [string, ...string[]],
}).notNull(),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server