How to properly use TypeScript types from @types/airtable package

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

Here’s what I’m trying to do:

import AirtableLib, { Database } from "airtable";

const db : Database = AirtableLib.base("my-base-id");

But I keep getting this error in my IDE:

'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 becomes any which doesn’t help with type checking. What’s the correct way to import and use these type definitions? Am I missing something basic about how TypeScript type imports work?

Database isn’t a type export from the airtable package - it’s a class constructor. The @types/airtable definitions don’t export a Database type you can use directly.

You want the return type of AirtableLib.base(). Here’s how I handle this:

import AirtableLib from "airtable";

type AirtableBase = ReturnType<typeof AirtableLib.base>;

const db: AirtableBase = AirtableLib.base("my-base-id");

This creates a type alias for whatever AirtableLib.base() returns and gives you proper typing.

Alternatively, just let TypeScript infer the type:

const db = AirtableLib.base("my-base-id");

I’ve worked with Airtable integrations for years and honestly, the second approach works fine for most cases. TypeScript will still catch type errors on the methods you call on db.

If you need explicit type annotation, stick with the ReturnType approach. The @types package has all the method signatures defined properly, so you’ll get full autocomplete and type checking either way.

hey, ur totally correct! Database ain’t a type - just use import Airtable from 'airtable'. the base method returns the types you need. keep it simple, lol