TypeScript module augmentation not working for Airtable automation development

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?

Your rollup bundler isn’t picking up the type definitions properly. I’ve hit this exact problem with external type packages.

First, make sure your global.d.ts is in your project root or in a types folder that’s referenced in your tsconfig.

But here’s the real fix - force TypeScript to load your augmentation before compilation. Try this:

Create a types.ts file instead of global.d.ts:

// types.ts
import '@airtable/blocks';

declare module '@airtable/blocks' {
  interface Table {
    selectRecordAsync(id: string, options?: any): Promise<any>;
  }
}

Then import this at the top of your automation.ts:

// automation.ts
import './types'; // This forces the augmentation to load
import { helperFunction } from './utils';

const myTable = base.getTable('Tasks');
const item = await myTable.selectRecordAsync('recABC123', { fields: ['Title'] });

Rollup sometimes ignores .d.ts files during bundling, but importing a .ts file with your declarations works every time.

Also check your rollup config - make sure it’s not excluding type files from the bundle.

I’ve encountered a similar challenge with TypeScript and third-party libraries. It’s possible your global.d.ts file isn’t recognized during the compilation process. Ensure your tsconfig.json includes this file in the files array or that your include patterns account for it. Additionally, try adding import '@airtable/blocks'; at the beginning of your global.d.ts before the declare module statement. In my experience, placing the module augmentation directly in the file where it’s being utilized tends to make TypeScript recognize changes more effectively.