twemoji-parser
twemoji-parser copied to clipboard
Add TypeScript types
This PR adds TypeScript types and links to them in the package.json file.
Adding TS definitions here implies that this project will keep them up to date. Since this project is already Flow-based, I'd prefer not to maintain both. If there's a way to automatically keep the TS definitions in sync with the Flow code, I'd accept this PR. Otherwise, I think DefinitelyTyped would be a more appropriate place for these definitions.
@n8downs yeah, this is definitely a commitment to keeping the types up to date. Given both the low commit frequency to twemoji-parser and the fact that the types themselves are only ~15 LOC in total, I’d say that the types becoming wildly out-of-date is not going to be a huge problem.
As far as maintenance burden goes, we could add a line in the README explaining that the types are third-party contributions and welcome TypeScript PRs.
Regarding an automated solution: I would love a solution for generating types from Flow code, but the flow tooling support is just not there yet and most likely won’t be for quite some time. It’s not even possible to get an entire typed AST from Flow (see this almost four-year-old[!!!] issue: https://github.com/facebook/flow/issues/248). If you’re open to converting this library to TypeScript, we can very easily go the other way though (most likely using flowgen).