JUCE
JUCE copied to clipboard
Add Typescript type definitions to javascript frontend library
Hi! I have been trying out the new WebView features in v8, and I noticed that the current frontend library is incompatible with Typescript.
I am submitting this PR to add a simple type declarations file to the existing project. Without type definitions, Typescript users either cannot use the library, or must disable type checking for this library, which means they also have no access to the JSDoc documentation you've written. This fix is similar to releasing @types types for javascript code, but as this library is not a published npm package I figure colocating the definitions may be the best solution, at least in the short term.
The only downside to this is that it creates an additional source of truth for function annotations (JS users see the original JSDoc comments, while Typescript users can only see them if they are in the .d.ts file.) The only better solution I know of is to fully migrate to Typescript, so for that reason it is very common to maintain types and JS code separately for libraries not originally written in typescript.
Most of the index.d.ts file was generated automatically by the typescript compiler, plus a handful of my corrections.
Let me know if I can improve anything or if I can help answer any questions about how these definitions work. I am already using them on one project and they have been working flawlessly so far.
Thanks!