cburgmer / rasterizeHTML.js

Renders HTML into the browser's canvas
http://cburgmer.github.io/rasterizeHTML.js
MIT License
2.45k stars 220 forks source link

Add TypeScript type definitions #197

Closed orentrutner closed 7 years ago

orentrutner commented 7 years ago

TypeScript type definitions based on the 1.2.4 documented interface. Gruntfile was modified to include the typings under dist/ and package.json was modified to reference the typings, such that TypeScript apps can find it.

https://github.com/cburgmer/rasterizeHTML.js/issues/184

cburgmer commented 7 years ago

Looks good, nice work! You should have received an invite from Github to join the project, feel free to merge yourself.

Once question on the doc strings. I believe we will have to maintain them when updating the API page in the wiki. Do they show up in tooling (e.g. IntelliJ), i.e. useful to the user? So are they worth the additional burden? If yes, happy to keep of course!

orentrutner commented 7 years ago

Thank you, will merge.

Yes, the jsdoc strings show up in at least some of the tooling. I know for certain that vscode formats them quite nicely upon hover and auto-completion, including parameters, object members, bullet points and code examples. I suspect that TypeScript editor plugins that leverage tsserver for parsing can/do surface them as well. But I didn't do an exhaustive review.

I understand that maintaining the comments introduces additional, ongoing burden. It's a valid concern. If you choose to strip out the comments, I'm happy to edit and delete them from the file. I will not take offense, of course, if you just wipe them out in the future.

In the vast majority of cases, the text is a direct copy+paste from the API wiki page. I added maybe a couple of sentences when context was clear in the wiki but wasn't in the isolation of code comments. My hope is that text maintenance, for the most part, is limited to remembering to copy the text from the wiki when it's updated.

There is also, of course, an ongoing concern of updating the typings when the library's code interfaces change. I'm happy to volunteer to make those changes.

cburgmer commented 7 years ago

Great stuff, welcome on board! Hope the grunt config was not to much a pain :)