define a jsonb column with `{}` as default value does not work

I'm trying to define a jsonb column with default value like this:

  attrs: pg
    .jsonb('attrs')
    .$type<Record<string, JSONValue>>()
    .default(sql`'{}'::jsonb`),


however, the inferred type definition of attrs still be Record<string, JSONValue> | null. How to get rid of the
null
?
Solution
attrs: pg
    .jsonb('attrs')
    .$type<Record<string, JSONValue>>()
    .default(sql`'{}'::jsonb`).notNull(),
Was this page helpful?