Code Monkey home page Code Monkey logo

Comments (10)

dy avatar dy commented on June 3, 2024

Nah, there's no types yet. You can add if you want!

from audio-decode.

flazouh avatar flazouh commented on June 3, 2024

How do you make this work in a typescript project then correctly?

from audio-decode.

dy avatar dy commented on June 3, 2024
{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
  }
}

in tsconfig.json

from audio-decode.

haouarihk avatar haouarihk commented on June 3, 2024

i hacked this quick types

declare module 'audio-decode' {
  function wav(data: Buffer): Promise<AudioBuffer>;
  function mp3(data: Buffer): Promise<AudioBuffer>;
  function flac(data: Buffer): Promise<AudioBuffer>;
  function opus(data: Buffer): Promise<AudioBuffer>;
  function qoa(data: Buffer): Promise<AudioBuffer>;
  function oga(data: Buffer): Promise<AudioBuffer>;
}

note: make a file called global.d.ts and put this there.
preferbly in d folder

from audio-decode.

dy avatar dy commented on June 3, 2024

Added jsdoc. Hope it will suffice

from audio-decode.

DaniGuardiola avatar DaniGuardiola commented on June 3, 2024

@dy it does not suffice. There are no types available, need to generate declaration files (which you should be able to do from the JSDoc you already wrote) or publish them on definitely typed. Let me know if you're looking for help here, I wouldn't mind putting up a PR.

from audio-decode.

dy avatar dy commented on June 3, 2024

Sure, PR is welcomed!

from audio-decode.

DaniGuardiola avatar DaniGuardiola commented on June 3, 2024

@dy unfortunately I won't be using this package anymore but I'm still happy to guide you through it if you want. The gist of it is that you'll need to generate .d.ts files with tsc and publish them alongside the .js files. In your case there's only one file you need to do that for: audio-decode.js. So, add typescript as a dev dependency, add a simple .tsconfig.json file that only includes that one file and has stuff like allowJs: true and declaration: true, and a prepare script (for example) that runs tsc to generate the audio-decode.d.ts file.

Alternatively, you could always simply maintain the types in a declaration file directly so that you don't need to generate them every time.

In any case, make sure to add a reference to the types in the package.json. Let me know if I can help with anything.

from audio-decode.

dy avatar dy commented on June 3, 2024

Ok, added. Thanks!

from audio-decode.

DaniGuardiola avatar DaniGuardiola commented on June 3, 2024

Glad I could help!

from audio-decode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.