googleapis / googleapis/google-cloud-node
[FR] Typed version of doc(), collection() and collectionGroup methods
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
`Firestore.doc(...)`, `Firestore.collection(...)` and `Firestore.collectionGroup(...)` all return Typed return value and the type is carried over nicely to all underlying functions.
However, we have no way to actually nicely input the type. This forces to write code that is prone to breaking as it contains casts:
```ts
const collectionRef = firestore.collection('contracts/' + customerKey + '/drafts') as CollectionReference
```
The correct TS way would be to be able to write
```ts
firestore.collection('contracts/' + customerKey + '/drafts')....
```
The current type is
```ts
collection(collectionPath: string): CollectionReference;
```
It should be
```ts
collection(collectionPath: string): CollectionReference
```
The same should be applied for .doc and .collectionGroup.
Contributor guide
Assessment
This issue has not been assessed yet.