Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #40 and #59, this PR adds a definitions file (index.d.ts) that provides typings for the library. Due to current TS limitations with respect to variadic types, the syntax is a bit messy. These types will support up to 10 components being passed in in the
components
prop. Up to 5 arguments are supported when the render function is non-unary. If you are aware that common usage of react-composer would exceed these numbers, then I can certainly make the types support more, but my experience of render-props components is that these are probably high-end for how people are likely to use them.The index.d.ts file is located in the src file, alongside the index.js for which it defines types. I have added a
cp
command at the end of the npm build script to move this to an appropriate directory that is included in the npm distribution.It adds a dev dependency on @types/react - this is only really present to make it easier to work with the definitions in the future should they need improvement/change. It should have no impact on the distributed bundles.
There is example usage of these types in comments at the top of the index.d.ts file. These can copied to test the types work as expected, but also serve as a reference for TypeScript users - when using new typings it is common to view their definitions, and examples are most likely to be seen in this file.
Please let me know if you have any comments or improvements, or if the types don't work correctly in any way.