#6513·knex

QOL Feat: Infer types from typed raw in keyed select

Author: exoRiftCreated Aug 11, 2026Updated Aug 11, 2026

Problem:

In the following query:

typescript
const result = await knex('table')
  .select({
    alias: db.raw<string>('foo::text')
  })
  .finally()

result[number].alias is of type any.

Solution:

Infer the string type from the raw in deferred key selection