Skip to content

bug: AirtableFieldSet does not expose type matching Airtable Formula fields with error #645

Description

@martinse

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.:

type FormulaFieldType = string;
type FormulaFieldErrorType  = { error: string; };

export interface MyTable extends AirtableFieldSet {
    ID: number;
    MyFormulaField: FormulaFieldType | FormulaFieldErrorType
}

Gives:

TS2411: Property  MyFormulaField  of type  string | FormulaFieldErrorType  is not assignable to  string  index type
string | number | boolean | Collaborator | Collaborator[] | string[] | Attachment[] | undefined

The actual response data looks like this from within Trigger.dev:

[
  {
    "id": "recXXX",
    "fields": {
      "ID": 1,
      "ValidFormulaField": "Some value",
      "InvalidFormulaField": {
        "error": "#ERROR!"
      },
      ...
    }
  }
]

Reproduction repo

n/a

To reproduce

  • Create a table in Airtable, containing a formula field with an error
  • Create a TypeScript interface that represents the formula field as type string
  • Fetch the data through @trigger.dev/airtable
  • The result should contain an error object
  • Try update the TypeScript interface with a type that can handle both a valid value and the error object

Additional information

Suggested fix: Add | {key: string} to AirtableFieldSet field type.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions