orchid-orm icon indicating copy to clipboard operation
orchid-orm copied to clipboard

`narrowType` doesn't work with `get()`

Open mordechaim opened this issue 8 months ago • 1 comments

Suppose I want to narrow a type but return in get:

db.book.find(1).get('name').narrowType()<number>()

the type is ignored:

This doesn't work either:

db.book.find(1).narrowType()<{ name: number }>().get('name')

mordechaim avatar Apr 23 '25 22:04 mordechaim

I could just use as number, but the get could also be part of a subquery.

mordechaim avatar May 02 '25 14:05 mordechaim

I published a fix:

// 1st is supported now:
db.book.find(1).get('name').narrowType()<number>()

// 2nd is not supported,`get` isn't aware of previously narrowed types:
db.book.find(1).narrowType()<{ name: number }>().get('name')

romeerez avatar May 25 '25 06:05 romeerez