deepgram / deepgram-js-sdk

Official JavaScript SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
128 stars 46 forks source link

Typescript typings #55

Closed sircon closed 1 year ago

sircon commented 1 year ago

What is the current behavior?

I'm trying to upgrade from ~1.3.1 to the latest package version ~1.4.5 and all the imports from this package are now throwing the following error:

File '.../node_modules/@deepgram/sdk/dist/index.d.ts' is not a module.ts(2306)

What's happening that seems wrong? Looking into the index.d.ts from both versions they're definitely different, and the version from 1.3 was exporting the Deepgram module and now it doesn't seem so.

Steps to reproduce

  1. Start a typescript project
  2. Install the latest version from the SDK: yarn add @deepgram/sdk@latest;
  3. Import the sdk import { Deepgram } from '@deepgram/sdk';
  4. Typescript will give an error.

Expected behavior

I'd expect to import not only the main Deepgram class, but also many other different types such as: PrerecordedTranscriptionResponse, WordBase, etc.

Please tell us about your environment

Other information

https://stackblitz.com/edit/typescript-vbkaj4?file=index.ts you might need a bit for it to fully load the linter but the result will be the same as the image: image

michaeljolley commented 1 year ago

Amazing find and detail @sircon! We're on this now.

michaeljolley commented 1 year ago

Thanks again for reporting this @sircon. Version 1.4.7 has just been released and should have resolved this.

I tested in a StackBlitz that you can check out here: https://stackblitz.com/edit/typescript-g4e1dm?file=index.ts

sircon commented 1 year ago

Thanks for the fix @MichaelJolley but... although the Deepgram works now, there are some issues with other types. In version 1.3.1 I could import PrerecordedTranscriptionResponse and WordBase form your package and now it doesn't seem to find it anywhere. Looking at your dist folder, it looks like you are missing two important folders you had before types/index.d.ts and the transcription/index.d.ts.

image

Do you think you can add these too?

sircon commented 1 year ago

For reference, how it looked before:

image

I could just copy & paste the interfaces, but obviously having it always up to date with the package would be the ideal situation!

michaeljolley commented 1 year ago

Ugh. Can't believe I missed that. 1.4.8 should have them restored.

sircon commented 1 year ago

Works great @MichaelJolley, thanks for the quick fixes!