bijoutrouvaille / fireward

A concise and readable language for Firestore security rules, similar to Firebase Bolt.
MIT License
238 stars 4 forks source link

timestamp missing toDate() #14

Closed JakeHedman closed 4 years ago

JakeHedman commented 4 years ago

The timestamp type is missing a few functions, toDate is the one I mainly care about. :)

https://firebase.google.com/docs/reference/node/firebase.firestore.Timestamp.html#to-date

bijoutrouvaille commented 4 years ago

Thank you, @JakeHedman. To solve this issue I've made small adjustments to the timestamp typing.

Now the generated .ts file will export a WardTimestamp type that follows the official docs you linked above. The file will also export an isTimestamp function, which is a type predicate for the aforementioned WardTimestamp. So you'll be able to type-safely do something like if (isTimestamp(data.stamp)) console.log(data.stamp.toDate());.

All this should be available as v 1.2.3.