question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use shared TypeScript definitions for common types such as CollectionReference, DocumentReference, WhereFilterOp, etc.

See original GitHub issue

I use Firestore both on the back-end and front-end environments. The problem is that the client library uses @firebase/firestore-types package (https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore-types/index.d.ts) while in Node.js types are defined in @firebase/firestore (https://github.com/googleapis/nodejs-firestore/blob/master/types/firestore.d.ts). For the most parts, the interfaces are identical, but because they’re defined individually, it prevents me from using shared helpers that I can use both in the browser and on the server.

For instance, I’m trying to create typed wrapper:

screen recording 2018-08-24 at 01 14 pm

But I can’t make it work in both environments because it depends on defenition of CollectionReference, DocumentReference, WhereFilterOp, etc:

image 2018-09-13 at 10 10 59 am

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
garyocommented, Jul 22, 2020

@kossnocorp this is great – Google, please consider adding this layer! Would be very helpful for all of us using Firebase on front end and back end.

3reactions
kossnocorpcommented, Feb 26, 2020

@Robula yeah, I’ve built a universal wrapper for Firestore: https://github.com/kossnocorp/typesaurus

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use shared TypeScript definitions for common types such as ...
Use shared TypeScript definitions for common types such as CollectionReference, DocumentReference, WhereFilterOp, etc. #1225.
Read more >
firebase/firestore - JavaScript API reference - Google
enableNetwork(firestore), Re-enables use of the network for this Firestore instance ... This is needed to distribute union types such as undefined | {....
Read more >
Firestore CollectionReference and DocumentReference types ...
I am using Firestore with React and Typescript. I'm trying to get some data from a firestore and update it. I have seen...
Read more >
Make sharing TypeScript code and types quick and easy
Explore the ways you can save time and more easily share the TypeScript code and types you and your team need in this...
Read more >
firebase/index.d.ts - UNPKG
136, * A string indicating the name of the package that made the log call,. 137, * such as `@firebase/firestore`. 138, */. 139,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found