thangngoc89 / react-howler

A React.js wrapper for howler.js (audio player)
https://khoanguyen.me/react-howler/
MIT License
364 stars 83 forks source link

Switch to TypeScript #99

Open ilyasakin opened 4 years ago

ilyasakin commented 4 years ago

So, it is no secret that this package lacks TypeScript support. Yeah @types/react-howler exists but most of the time it's out of sync.

Also with this switch we can directly cast react-howler's props to howler and use the types from @types/howler for props (also proper auto-complete support is huge bonus). So every time howler gets updated all we need to do is update howler and @types/howler.

Stenerson commented 4 years ago

I'm not opposed to adding TypeScript support, I've just never used it and – nothing against TypeScript – but I don't have the time or desire to learn it right now.

What's involved in adding support? I'm mostly just not sure how I can support it without understanding it. 🤷‍♂️ Ideas very much welcome.

ilyasakin commented 4 years ago

Adding support involves creating d.ts files that have same names with js files and declare the types in them.

For instance, you need to create app.d.ts for app.js in same directory (you can place them in separate folder though). Then all you need to do is declare types for functions, classes with declare keyword.

These links should give you brief information about d.ts:

Also you can take a look at @types/react-howler/index.d.ts

Stenerson commented 4 years ago

Thanks for the resources @iakindev. Unfortunately this just isn't something I'm going to be able to help much with... I'd happily accept a PR (especially if the TS definitions can be kept apart from the actual source to avoid source churn) but I would need community help with validation of the PR because like I said, I don't have the time or interest to learn this to a level where I'd be comfortable giving it the :shipit: myself.

If a PR were submitted and was given the stamp of approval by members of the community, I think it'd be easy enough to keep it up to date in the future. As has been discussed before and most already know, this package is pretty "feature mature" in the sense that it's just a convenient React wrapper around Howler. I don't see major things changing so I'd hope that TS support would be easy enough to maintain for future changes.

slightlybelowzen commented 1 year ago

hey, so I'm using typescript and I've used react howler before so if you're still looking for a PR I'd be happy to start working on one!

Stenerson commented 1 year ago

Hey @pn320, thanks for the comment. My views are pretty much the same as they were in my last comment. I'm using this package in production in a web app that has quite a bit of use and I'm personally not looking to add new features or create more maintenance to this package.