Skip to content
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

Add TypeScript support #51

Closed
vahdet opened this issue Aug 7, 2020 · 4 comments
Closed

Add TypeScript support #51

vahdet opened this issue Aug 7, 2020 · 4 comments

Comments

@vahdet
Copy link

vahdet commented Aug 7, 2020

Firstly, thanks for the promising work!
In my case, the basic import (import SpeechRecognition, { useSpeechRecognition } from 'react-speech-recognition') fails the TypeScript check with code ts(7016):

Could not find a declaration file for module 'react-speech-recognition'. '.../my-proj/node_modules/react-speech-recognition/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-speech-recognition` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-speech-recognition';`

And npm install @types/react-speech-recognition throws:

Not Found - GET https://registry.npmjs.org/@types%2freact-speech-recognition - Not found

So, I had to workaround it with adding this in my app.d.ts file:

declare module 'react-speech-recognition';

So, do you have any agenda for adding TypeScript support? If needed, I also may contribute at my best effort.

@JamesBrill
Copy link
Owner

Hi @vahdet thanks for the suggestion. I have no experience with TypeScript (though it is of interest to me), so you may be better positioned to contribute a declaration file than me. If you make a PR for this, I can advise on the types and shape of the inputs/outputs.

You probably don't even need to do the whole thing - if you get it started and help me get an idea of how to structure and publish a declaration file, I can probably fill in the missing definitions.

@vahdet
Copy link
Author

vahdet commented Aug 8, 2020

@JamesBrill Well, yesterday I tinkered with the code indeed. I forked the repo applied my work on a new branch feature/typecript-support. I have some experience with TypeScript, but cannot call myself a master of it. Anyways, I am sending a PR w/ my further explanation on what I've done; and then, improvements can be done on it (see: #52)

I won't be around for a couple of weeks, so I may react slower than today..

@OleksandrYehorov
Copy link

@vahdet @JamesBrill @types/react-speech-recognition is now available.

@JamesBrill
Copy link
Owner

Thank you @OleksandrYehorov - that is hugely appreciated. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants