ianstormtaylor / react-values

A set of tiny React components for handling state with render props.
https://git.io/react-values
MIT License
1.01k stars 39 forks source link

TypeScript definitions. #8

Closed theKashey closed 6 years ago

theKashey commented 6 years ago

Any plans to add d.ts, or happy if someone else will create it?

ianstormtaylor commented 6 years ago

Hey @theKashey! I don't really use or know TypeScript myself, so I'd ask that instead the definitions be contributed to DefinitelyTyped (or whatever the best practice is) so that others can maintain them independently of this library, since I won't know how to update them. But that would be awesome to have!

theKashey commented 6 years ago

That's an open question - I personally prefer to have d.ts as a part of a library, as long it's much easier to synchronize API changes. Someone prefers them in DefinitelyTyped, but it is much harder to maintain them, as long it becomes "two dimensional".

The best practice - have a d.ts here, and have a simple "smoke" test also here.

Anyway - for all the time I've used react-powerplug without types - I always (~twice a day) mess with render props. Like

<Value> {(value, setValue)}
//not
<Value> {({value, setValue})}

This sort of mistake is hard to spot, but easy to type.

RenderProps and Types shall come together.

theKashey commented 6 years ago

(could you assign this issue to me?)

ianstormtaylor commented 6 years ago

For my take on this, after trying to work with the times from #25 myself, please see: https://github.com/ianstormtaylor/react-values/pull/25#issuecomment-412176112