I’m building a TypeScript development setup for Airtable automations and using rollup to bundle external libraries. I’m working with @airtable/blocks package for type definitions since it’s the closest match to the Airtable automation runtime.
The problem is that I need to add a missing method selectRecordAsync to the Table interface, but my module augmentation isn’t being recognized by TypeScript.
// automation.ts
import { helperFunction } from './utils';
const myTable = base.getTable('Tasks');
// TypeScript error here - selectRecordAsync doesn't exist
const item = await myTable.selectRecordAsync('recABC123', { fields: ['Title'] });
helperFunction(item.getCellValueAsString('Title'));
export {};
// global.d.ts
import { type RecordQueryResultOpts } from '@airtable/blocks/dist/types/src/models/record_query_result';
import type TableOrViewQueryResult from '@airtable/blocks/dist/types/src/models/table_or_view_query_result';
declare module '@airtable/blocks' {
interface Table {
selectRecordAsync(id: string, options?: RecordQueryResultOpts): Promise<TableOrViewQueryResult>;
}
}
declare global {
const base: typeof import('@airtable/blocks').base;
const input: {
config(): any;
};
const output: {
set(key: string, value: any): void;
};
}
TypeScript still throws an error:
automation.ts → build...
(!) [plugin typescript] Error TS2551: Property 'selectRecordAsync' does not exist on type 'Table'.
Did you mean 'selectRecordsAsync'? automation.ts:4:32
4 const item = await myTable.selectRecordAsync('recABC123', { fields: ['Title'] });
How can I properly extend the Table interface without modifying the original @airtable/blocks source files?