Closed martinse closed 12 months ago
@martinse do you happed to know if the official Airtable Node SDK supports this?
We're just wrapping their SDK and it's possible we've done something incorrect with the types we pass to their generic function.
Looking at the types from the official Airtable SDK I see the similar type def:
export interface FieldSet {
[key: string]: undefined | string | number | boolean | Collaborator | ReadonlyArray<Collaborator> | ReadonlyArray<string> | ReadonlyArray<Attachment>;
}
Also reading their documentation at https://airtable.com/developers/web/api/field-model#formula it might be that they haven't defined the type correctly:
Cell format (read only)
string | number
I can't find any reference to this error object that I get back in their documentation. I was thinking perhaps Trigger.dev defined their own types due to the custom type in @trigger.dev/airtable
but it seems as it just mirrors the official SDK type.
Just did some testing and you would have to extend that error type further, e.g. due to division by zero:
type FormulaFieldErrorType = { error: string } | { specialValue: "Infinity" | "NaN" };
As you verified, types are indeed incorrect in the official SDK.
Sadly, I can't recommend opening an issue in their repo. It seems largely unmaintained. There are still valid open issues from 5 years back that haven't received any attention.
I don't see a way to fix this nicely from our end - we'll likely have to resort to // @ts-ignore
in a few places.
Provide environment information
❯ npx envinfo --system --binaries
System: OS: macOS 13.5 CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz Memory: 34.34 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.8.0 - ~/.volta/tools/image/node/20.8.0/bin/node npm: 10.1.0 - ~/.volta/tools/image/node/20.8.0/bin/npm pnpm: 8.7.6 - ~/.volta/bin/pnpm Watchman: 2023.09.04.00 - /usr/local/bin/watchman
Describe the bug
AirtableFieldSet
does not expose correct type for Airtable Formula fields with errors.When creating a type/interface to represent an Airtable record with formulas - if the formula inside Airtable has errors, this cannot be typed through
@trigger.dev/airtable
.E.g.:
Gives:
The actual response data looks like this from within Trigger.dev:
Reproduction repo
n/a
To reproduce
string
@trigger.dev/airtable
Additional information
Suggested fix: Add
| {key: string}
toAirtableFieldSet
field type.