Text Enum Typing
I'm getting a type error that I don't understand
Was able to resolve by casting but doesn't make sense to me
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(),
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