You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we incorporate strong typing into query, orderBy and where? For example, I would like query and where to automatically work for these:
constcol= ... asCollectionReference<{s: string;o: {n: number};a: number[]}>query(col,where('s','in',['a','b']))// is correctly typedquery(col,where('o','==',{n: 2}))// is correctly typedquery(col,where('a','array-contains',2))// is correctly typedquery(col,where('a','array-contains-any',[2,3]))// is correctly typedquery(col,where('s','==',2))// is *incorrectly* typedquery(col,where('s','==',['a']))// is *incorrectly* typed
The update function already has strong typing (through UpdateData). Ideally, we would have the same strong typing for where. I've created a thin layer that implements strong typing query, orderBy and where to demonstrate this: https://github.com/tianhuil/firebase-proto
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Can we incorporate strong typing into
query
,orderBy
andwhere
? For example, I would likequery
andwhere
to automatically work for these:The
update
function already has strong typing (throughUpdateData
). Ideally, we would have the same strong typing forwhere
. I've created a thin layer that implements strong typingquery
,orderBy
andwhere
to demonstrate this: https://github.com/tianhuil/firebase-protoIt has type assertions to verify correctness: https://github.com/tianhuil/firebase-proto/blob/main/assert/where.ts
Would you be open to me adding this directly to firebase?
Beta Was this translation helpful? Give feedback.
All reactions