kevlened/fireway

Typescript: Incorrect type for FieldValue

optimistiks opened this issue · 1 comments

Imagine you have this (Renamed FieldValue to fv to avoid confusion below).

function migrate({ firestore, FieldValue: fv }: MigrateOptions) {}

So in this case, if you do something like

const timestamp = fv.serverTimestamp()

Typescript will complain: Property serverTimestamp is a static member of type FieldValue.

It's because fv is typed as instance of class FieldValue, not the class FieldValue itself.

The solution would be to type it like this FieldValue: typeof FieldValue.

I haven't checked, but it might be the case for FieldPath and Timestamp as well.

Excellent. Thanks! I don't use TypeScript in my day-to-day, so any feedback is appreciated.

This is published in fireway@1.0.2