joshwcomeau / react-flip-move

Effortless animation between DOM changes (eg. list reordering) using the FLIP technique.
http://joshwcomeau.github.io/react-flip-move/examples
MIT License
4.09k stars 258 forks source link

Fix TypeScript typings #165

Closed vsaarinen closed 7 years ago

vsaarinen commented 7 years ago

Version 2.9.13 completely broke react-flip-move for me as a TypeScript user. I'm not fully versed in how the different module/bundling systems work, but it seems that the included bindings exported the type definitions in a way that wasn't aligned with how the component is actually exported. The included test TypeScript file compiled ok, but once you tried to use the component in a TypeScript application, everything blew up at runtime.

Using the export = method in the type definitions fixes these problems. This PR is based on the @types/react-flip-move package's typings with a few additional fixes (the addition of the style and verticalAlignment props) and a combination of tests from both definitions.

The tests can be run (compiled) by running the following command inside typings/:

$ tsc --jsx react ./test.tsx

Note: I'm personally not very experienced with publishing type definitions, so there may be some errors here. However, the @types/react-flip-move definitions have worked well for me so far, and everything seemed to work when I replaced the published NPM package's react-flip-move.d.ts file with the one included in this PR.

vsaarinen commented 7 years ago

@Hypnosphi Was there still something that should be fixed?

Hypnosphi commented 7 years ago

No, looks good to me