fauna / faunadb-js

Javascript driver for Fauna v4 (deprecated)
https://docs.fauna.com/fauna/v4/
Other
702 stars 76 forks source link

Update Expr.d.ts #676

Closed william1616 closed 1 year ago

william1616 commented 1 year ago

Notes

This is a minor proposed change to correct the type definition of the Expr class - Expr.d.ts was missing the toJSON function so in typescript environments it wasn't possible to call Expr.toJSON()

Example below using faunadb-js@4.8.0 image

ptpaterson commented 1 year ago

Hi @william1616 and thanks for the submission!

You've been working with my colleague, Zee, and I gave him bad advice. I am sorry for the confusion, but Expr.toJSON() is not necessary for you to call, so the method does not need to be public.

In order to get the wire-protocol representation of the FQL query, you may execute JSON.stringify(x).

This works because all FQL functions are Expr instances and when you use JSON.stringify it picks up the custom toJSON function.

Please let us know if that solves the problem. If so, we can close this PR. If not, we'll keep working on it.

Thanks!

william1616 commented 1 year ago

thanks @ptpaterson (just replied with you on cc to Zee's email) - i'll close this PR