TypeScript type definitions from DefinitelyTyped - how to properly import for Airtable

I’m still learning TypeScript and having trouble with type imports. I installed the @types/airtable package to get type definitions for the Airtable library, but I can’t figure out how to use them correctly.

Here’s what I’m trying to do:

import AirtableClient, { Database } from "airtable";

const myDatabase : Database = AirtableClient.base("my-base-id");

But I keep getting this error in my editor:

'Database' refers to a value, but is being used as a type here. Did you mean 'typeof Database'?ts(2749)

When I try using typeof Database instead, the type just shows up as any which doesn’t seem right either. What’s the correct way to import and use these type definitions? I feel like I’m missing something basic about how TypeScript type imports work with external libraries.

This is a super common issue when you’re starting with TypeScript and external libraries. The problem is that Database isn’t exported from the airtable package.

You want the Base type instead. Here’s how I handle it:

import Airtable, { Base } from 'airtable';

const myDatabase: Base = Airtable.base('my-base-id');

If that doesn’t work, try the return type approach:

import Airtable from 'airtable';

const myDatabase: ReturnType<typeof Airtable.base> = Airtable.base('my-base-id');

Pro tip: check the actual type definitions file when you hit these issues. Look at node_modules/@types/airtable/index.d.ts to see what’s actually exported. Saves you from guessing what types are available.

That typeof suggestion from your editor was trying to help, but it’s wrong here - you need the instance type, not the constructor type.

airtable’s types can be a bit confusing. try importing like import Airtable from 'airtable' and use Airtable.Base for your db. like this: const myDatabase: Airtable.Base = Airtable.base('my-base-id') - that fixed it for me!