Column name `as string`, needed for performance?

I joined my first project with drizzle about a year ago. I noticed that all columns definitions were including as string or as const after the name. When I asked about it I was told this was needed for performance of the type system, and they didn't go into too much detail about it. Is that true? are these casts needed for the TS server to be able to keep up with all the types gymnastics in the library? Or can we safely remove them already?
1 Reply
Aarón Contreras
Aarón ContrerasOP7d ago
example:
pgTable('tv_shows', {
id: serial('id' as string).primaryKey(),
name: text('name' as string)
.notNull()
.unique(),
channelId: integer('tv_channel_id' as string).references(() => tvChannels.id),
})
pgTable('tv_shows', {
id: serial('id' as string).primaryKey(),
name: text('name' as string)
.notNull()
.unique(),
channelId: integer('tv_channel_id' as string).references(() => tvChannels.id),
})

Did you find this page helpful?