feedhenry/fh-sync

Add TypeScript definition tests

Opened this issue ยท 5 comments

I was thinking about the idea of testing/maintaining compatibility of the declaration file with the JavaScript implementation in the longer term.

Perhaps the best way to ensure the TypeScript declaration file is always in sync with the JavaScript implementation would be to write the tests for this repo in TypeScript. This would ensure that they are always aligned (interface-wise) as the tests would fail if they weren't.

I think this would result in the RainCatcher team not having to be so attentive to the declaration file (leaving other contributors to forget about the TypeScript part), instead the maintenance of it would be shared among anyone who makes a PR.

@aidenkeating

@wtrocki ๐Ÿ‘ Following on from Wei's comment, perhaps we could roadmap rewriting this repo in TypeScipt? This could be the first (or one of the first) tasks in that milestone (GitHub milestone ๐Ÿ˜œ ). WDYT?

From my point of view we may just need to improve our api to be little bit more object oriented and hide some more internal options from regular users. TypeScript source code may be good but only when we will consider more work on this - this may involve a lots of testing etc.

@aidenkeating @wtrocki yeah, I don't think we need a complete rewrite - I think majority of the changes will be adding new interfaces and types defs for many of the options, callbacks etc, and add TSDOC. Then we can generate the type definitions automatically.

We might just need some initial setup done first - e.g. adding the tasks to compile the TS and generate the definition file. Then the rest of the work can be done step by step - e.g. one file at a time, or even just one function at a time.

Would be nice to move it to TS given the relative complexity of the codebase. I find the most frequent issues with sync are caused not by sync, but rather misuse due to misunderstood docs/examples. TS could really improve developer experience so starting with .d.ts files would be great, and even porting piece by piece to TS might make maintainability and readability much better for the sync source code.

๐Ÿ‘ for the suggestions in here