-
Notifications
You must be signed in to change notification settings - Fork 19
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 declarations #21
Conversation
Adding yourself to contributors is fine, I should actually go and add contributors to the |
Resolves the TypeScript compiler throwing this error: Argument of type 'string | number' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'.
@atlasthebot I'm so sorry I didn't get to this earlier. I truly completely forgot. I've resolved the requested changes and I've also quickly fixed a minor typings issue you had in Index (since you had @ts-check enabled, VSCode was finding the issue). On a complete sidenote I was curious, what would you say to a complete rewrite of the lib into TypeScript? I've been doing a LOT of TypeScript work lately and I'd be willing to do that, but I need your green light since it will essentially change the code some what. It would be great if you could make that change to commonfy (and anything else pending) you said you would prior though as the compilation from TS to JS itself will generate the proper declaration files. on a related note also coming back to what you said:
It technically would but it is generally to be avoid to use commonJS require & module.export in TypeScript in favor of ES6 import & export. (not to mention that the compiler would trip on not defining types but that is beside the point). You can check some of my recent TypeScript work here (awesome-converter) and here (awesome-querystring) |
A rewrite in Typescript sounds neat, although I'd like to learn Typescript myself before considering it. |
It's definitely worth your time if you do a lot of JS work IMO. If it's your juice start with some videos from Microsoft Builds (the annual conference by Microsoft) concerning TypeScript to see some advantages it gives. Other than that trial and error in creating something I suppose. Fact that it is essentially just JS with some extra syntax helps. To give a bit of an idea on syntax difference here is some code of one of my libs in JS and here is the same in TypeScript (ignore the weird All that said GitHub isn't really the place to talk. You obviously have Discord judging by your other repos so if you wanna talk about this and the possible rework to TS of the lib hmu there: favna#1 |
I've recently picked up learning TypeScript and this lib didn't have a declarations file yet so yay here we go.
I also updated the README usage examples part so you can port that over to boorujs.org. And I hope you don't mind I added myself to contributors =P
Lastly I bumped the version to 1.3.5 while I was editing anyway.