-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored nodejs bindings to use typescript #546
base: master
Are you sure you want to change the base?
Conversation
Hi @mmende I'm sorry, I'm not very deep in all those JS things, does this change make things incompatible with plain JS? Should we just have 2 parallel version instead? |
Hi @nshmyrev No, this doesn't change anything when using the library with plain JS. The code is transpiled to pure JS and separate type declaration files ( |
Added setSpkModel and reset methods to recognizer.
Added getModelAsync and getSpkModelAsync which allow optionally loading models in a different thread |
@mmende Have you considered submitting this to DefinitelyTyped? This would be awesome to have, but there doesn't appear to be much appetite to merge it here. |
@alangibson Yes I thought about it. The problem with separate types however is, that I'd had to keep track of api changes within the vosk nodejs implementation to prevent wrong or outdated type definitions. I also thought about publishing a separate module as @nshmyrev already suggested (maybe something like |
I'd love to see the library to have official type support. If it doesn't get merged, It would be great to have the types seperately or the fork. While the fork is probably easier to maintain |
node_modules\ts-node\src\index.ts:859 307 const libvosk: VoskLibrary = ffi.Library(soname, { |
This PR contains a refactored version of the nodejs bindings using typescript.
This enables autocompletion and static code analysis when including the library in typescript or javascript projects.
JSDocs is a nice start, but when including the library within a typescript project, typescript will complain about a missing declaration file. Furthermore, as code is written in typescript itself, the declaration files doesn't have to be updated manually when working on the library.
I also added prettier and eslint for a consistent code style within the nodejs library and refactored the demo scripts so that the dependencies of the demos must not be included in the library itself.
The PR also makes it a little bit easier to work on the nodejs library by including a script that downloads the shared libraries for development and provides a watch server that reruns a test script once the code changes somehow.