inferInsert returns unexpected type?
Hello!
I'm probably just dumb but shouldn't a schema like this
be infered like using
to
instead of
Am I doing something wrong here?
Thanks
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(),
});
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];
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;
};
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
}
1 Reply
🤦♂️ You need to have strict mode set to true on tsconfig
sorry