Types are automatically configured in most IDEs when you import the assemblyai module using require or import.
However, if you're using the assemblyai.umd.js or assemblyai.umd.min.js script,
you need to manually reference the types.
-
Install the
assemblyaimodule locally. -
Create an assemblyai.d.ts file with the following content.
import AssemblyAIModule from "assemblyai"; declare global { const assemblyai: typeof AssemblyAIModule; }
This will import the TypeScript types from the
assemblyaimodule, and configure them as the globalassemblyaivariable. -
Reference the assemblyai.d.ts file at the top of your script file.
/// <reference path="assemblyai.d.ts" /> const { RealtimeTranscriber } = assemblyai; ...
Your IDE will load the types specified in the
<reference />tag.[!INFO] >
/// <reference />tags only work in script files, not script-blocks, and should be at the top of the file.