I’m trying to create a TypeScript dev env for my Airtable automations. Using rollup to bring in shared libs (which Airtable automations has no ability to do)
I’m using @airtable/blocks
which seems to have the closest type definitions for the Airtable automation runtime.
I’m stuck on the following table.selectRecordAsync
which doesn’t exist in @airtable/blocks
. My attempt to patch the definition isn’t working.
<code>// myAutomation.ts
import { mySharedFunc } from './lib';
const table = base.getTable('MyTable');
// type error at .selectRecordAsync
const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
mySharedFunc(record.getCellValueAsString('Name'));
export {};
</code>
<code>// myAutomation.ts
import { mySharedFunc } from './lib';
const table = base.getTable('MyTable');
// type error at .selectRecordAsync
const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
mySharedFunc(record.getCellValueAsString('Name'));
export {};
</code>
// myAutomation.ts
import { mySharedFunc } from './lib';
const table = base.getTable('MyTable');
// type error at .selectRecordAsync
const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
mySharedFunc(record.getCellValueAsString('Name'));
export {};
<code>// types.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(recordID: string, opts?: RecordQueryResultOpts): Promise<TableOrViewQueryResult>;
}
}
declare global {
const base: typeof import('@airtable/blocks').base;
const input: {
config(): any;
};
const output: {
set(key: string, value: any): void;
};
}
</code>
<code>// types.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(recordID: string, opts?: RecordQueryResultOpts): Promise<TableOrViewQueryResult>;
}
}
declare global {
const base: typeof import('@airtable/blocks').base;
const input: {
config(): any;
};
const output: {
set(key: string, value: any): void;
};
}
</code>
// types.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(recordID: string, opts?: RecordQueryResultOpts): Promise<TableOrViewQueryResult>;
}
}
declare global {
const base: typeof import('@airtable/blocks').base;
const input: {
config(): any;
};
const output: {
set(key: string, value: any): void;
};
}
Error
<code>myAutomation.ts → output...
(!) [plugin typescript] foo.ts (3:28): @rollup/plugin-typescript TS2551: Property
'selectRecordAsync' does not exist on type 'Table'.
Did you mean 'selectRecordsAsync'? myAutomation.ts:3:28
3 const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
</code>
<code>myAutomation.ts → output...
(!) [plugin typescript] foo.ts (3:28): @rollup/plugin-typescript TS2551: Property
'selectRecordAsync' does not exist on type 'Table'.
Did you mean 'selectRecordsAsync'? myAutomation.ts:3:28
3 const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
</code>
myAutomation.ts → output...
(!) [plugin typescript] foo.ts (3:28): @rollup/plugin-typescript TS2551: Property
'selectRecordAsync' does not exist on type 'Table'.
Did you mean 'selectRecordsAsync'? myAutomation.ts:3:28
3 const record = await table.selectRecordAsync('rec123', { fields: ['Name'] });
short of copying and modifying the src files in @airtable/blocks
, how can this be done?