ohanhi/hyperscript-helpers

TypeScript Definitions

TylorS opened this issue ยท 5 comments

Before anything I want to thank you for this awesome library! ๐Ÿ‘ ๐Ÿ‘

I've been experimenting with migrating Cycle.js over to TypeScript as well as some of it's drivers and I had the need to write some TypeScript definitions. I was wondering if that is something you would like to have PR'ed for your repo? I have them written here. I'll gladly rename/refactor things if you think it's necessary anywhere.

Thanks! I suppose this would be useful to people, yes. The only thing I'm wondering is if we could somehow make the thing DRYer - so that e.g. adding a tag wouldn't require changing both the source code and the TS definition. I have no experience on working with TS, so do you have any ideas?

I don't currently know of a better way to do this as a separate file, I just started learning/using TypeScript. The only way I know to keep from having to manually changing the TS definition is to write the source in TS as well, even then, the way things everything is dynamically created via an array of strings that might not even work as expected.

Welp, I guess we go with the separate file then. Can you add some kind of a test to make sure the definitions are up to date?

Sure, I'll definitely give that a go ๐Ÿ‘

I wasn't able to test it, but if you're okay with exporting TAG_NAMES from src/index.js I was able to write a short script that generates the definition file. I opened a PR with the possible changes