inferInsert returns unexpected type?

Hello! I'm probably just dumb but shouldn't a schema like this
export const subscriptions = pgTable('subscriptions', {
id: uuid('id').defaultRandom().primaryKey(),
userId: text('user_id')
.references(() => user.id)
.notNull(),
stripeCustomerId: text('stripe_customer_id').notNull().unique(),
productId: integer('product_id').references(() => products.id),
stripeSubscriptionId: text('stripe_subscription_id').notNull(),
status: subscriptionStatus('status').default('active'),
currentPeriodStart: timestamp('current_period_start').notNull(),
currentPeriodEnd: timestamp('current_period_end').notNull(),
});
export const subscriptions = pgTable('subscriptions', {
id: uuid('id').defaultRandom().primaryKey(),
userId: text('user_id')
.references(() => user.id)
.notNull(),
stripeCustomerId: text('stripe_customer_id').notNull().unique(),
productId: integer('product_id').references(() => products.id),
stripeSubscriptionId: text('stripe_subscription_id').notNull(),
status: subscriptionStatus('status').default('active'),
currentPeriodStart: timestamp('current_period_start').notNull(),
currentPeriodEnd: timestamp('current_period_end').notNull(),
});
be infered like using
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];
to
export type ExpectedType = {
userId: string;
stripeCustomerId: string;
productId?: number;
stripeSubscriptionId: string;
status?: string; //Enum values string for simplicity
currentPeriodStart: Date;
currentPeriodEnd: Date;
};
export type ExpectedType = {
userId: string;
stripeCustomerId: string;
productId?: number;
stripeSubscriptionId: string;
status?: string; //Enum values string for simplicity
currentPeriodStart: Date;
currentPeriodEnd: Date;
};
instead of
type ActualType = {
userId: string;
stripeCustomerId: string;
stripeSubscriptionId: string;
currentPeriodStart: Date;
currentPeriodEnd: Date;
//status and product missing
}
type ActualType = {
userId: string;
stripeCustomerId: string;
stripeSubscriptionId: string;
currentPeriodStart: Date;
currentPeriodEnd: Date;
//status and product missing
}
Am I doing something wrong here? Thanks
1 Reply
Kedalen
KedalenOP2w ago
🤦‍♂️ You need to have strict mode set to true on tsconfig sorry
Want results from more Discord servers?
Add your server