Modify the TypeScript module with globally scoped variable – TS scripting for Airtable

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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<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 {};
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<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?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật