I am currently creating a definition file for Airtable, and I have encountered an issue with the way they export their classes. They only provide one class like this:
...
module.exports = Airtable;
As a result, my airtable.d.ts
file looks something like this:
declare module "airtable" {
export type CustomType = { ... };
export class Airtable {
...
}
export = Airtable;
}
When I try to import the Airtable
class, everything works smoothly:
import Airtable = require("airtable");
...
new Airtable(...)
However, I am struggling to figure out how to import the CustomType
:
let a: Airtable.CustomType;
This line results in the following error:
'Airtable' is only referring to a type and cannot be used as a namespace here.
And when I try this approach:
import { CustomType } from "airtable";
I get these errors:
The module "airtable" does not have an exported member called 'CustomType'.
The module "airtable" resolves to a non-module entity and cannot be imported using this method.
Do you have any suggestions on how I can import other exported types while still utilizing export =
and import/require
?
Thank you.