coda-js
coda-js copied to clipboard
Add Model Field Typing
This should be relatively simple, but to have better TS support we should add the returned fields as typed properties on each model. This helps with autocomplete (even for JS users) and will overall tighten up the project code.
Currently the only fields being typed are mostly things that should be private to the package: https://github.com/parker-codes/coda-js/blob/330c170fa29fa39f61f1f55a00ca9185b8d6ee2d/src/models/Row.ts#L4-L9
A solution could be to create an interface for RowFields or something like that which has all of the fields returned from the Coda API. This interface can be used to type the create/update methods instead of using any:
https://github.com/parker-codes/coda-js/blob/330c170fa29fa39f61f1f55a00ca9185b8d6ee2d/src/models/Row.ts#L28
It's possible that we may need to add the fields to the main model as well as have interfaces for each individual CRUD operation that needs it though, in case some take different options.
We'll also want to mark some of the current fields as private so that they aren't exposed outside of the package.
Thanks for creating your first issue for coda-js and contributing!
Thank you, bot! 😂