You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you all have examples for working with Airtable and typescript?
In my base, I have a ✅ checkbox field (which I assume would be boolean, right?).
I have a component that is pulling in data from a single record, using this type: RecordData<FieldSet>.
Why when I get the data for that field fields.completed, is it showing the type as the following?
I would expect that having set the field "type" specifically in the base, that it would return as that particular type.
Or maybe I am not defining it correctly?
Here is a simplified example:
const Record = ((props: RecordData<FieldSet>)=>{
const { fields, id } = props
console.log("fields.completed", fields.completed)
const completed = fields.completed ? "yes, it is completed": "not completed"
return <>{completed}</>
})
The text was updated successfully, but these errors were encountered:
It's not going to be very easy to introspect your instance and setup you specific types and fields for the airtable js team. Most likely you'll need to do what I did and build a wrapper around their primitives that cast their fieldsets to your domain model
FYI I made a wrapper around the airtable library that's called airtable-ts that enables you to use the field / column types in your code (and gives you clear runtime errors if people edit tables and things no longer line up). This sounds similar to what @dopry might have built, but as a more general package than can be usedby others.
It also fixes weirdness with checkboxes, e.g. unchecked checkboxes are not returned from the API at all (e.g. you'd get undefined trying to access it), but airtable-ts treats that as actually false.
Do you all have examples for working with Airtable and typescript?
In my base, I have a ✅ checkbox field (which I assume would be boolean, right?).
I have a component that is pulling in data from a single record, using this type:
RecordData<FieldSet>
.Why when I get the data for that field
fields.completed
, is it showing the type as the following?I would expect that having set the field "type" specifically in the base, that it would return as that particular type.
Or maybe I am not defining it correctly?
Here is a simplified example:
The text was updated successfully, but these errors were encountered: