Description
As a blanket concept, it would be very useful to update the SDK's document create
and update
methods to accept a type param to better type the passed in document argument.
For example, the first overload for the Firestore DocumentReference#update()
method accepts a single firestore.UpdateData
argument which is lightly typed.
Example usage:
documentRef.update(data.doc);
It would be awesome if a user could supply an optional type param to update
which typescript would use to check the data.doc
interface.
For example:
documentRef.update<{name: string; age: number}>(data.doc);
Typescript would ensure that data.doc
had the interface {name: string; age: number}
.
This general concept would be widely useful across the SDK and I do not think it would be a breaking change. My immediate desire is for Firestore related methods, but I believe the typing for the entire library could be improved in some places.
An implementation example for the first overload of the DocumentReference
class:
update<T extends firestore.UpdateData = firestore.UpdateData>(value: T): Promise<void>;
Is this something you would accept PR's for?