Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 1.02 KB

reference-types-from-js.md

File metadata and controls

27 lines (22 loc) · 1.02 KB

Reference types from JavaScript

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.

  1. Install the assemblyai module locally.

  2. 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 assemblyai module, and configure them as the global assemblyai variable.

  3. 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.