Is there Typescript support?
See original GitHub issueI noticed that a type definition exist and I have read through some conversations on issues and PR that suggest some attempts have been done in order to support typescript however I’m currently trying to use it and I’m running into multiple errors.
I would like to know if currently, this package type definition is correct because it does not seem to be
I run into this error if I try the basic example on `"Type ‘{ value: string; label: string; children: { value: string; label: string; }[]; }[]’ is not assignable to type ‘Node[]’. Type ‘{ value: string; label: string; children: { value: string; label: string; }[]; }’ is not assignable to type ‘Node’. Types of property ‘label’ are incompatible.
If I change the way I import the package to const CheckboxTree = require('react-checkbox-tree');
then it works but without any type support
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
@djyako the
id
property was indeed missing from the TypeScript interface. I have pushed a commit to add it, but this is not on any npm release yet.As far as the issue @Luis-Palacios has, I am not quite sure what is different between
React.ReactNode
andJSX.Element
as they would have seemed like they would be synonymous.JSX.Element
was present in the initial PR to add TypeScript support so that is what I used for future enhancements.If
React.ReactNode
works for strings, numbers, JSX elements, and other React components, then I can easily update the interface, as that is whatPropTypes.node
essentially means.I am happy to provide TypeScript support given that the
interface
definitions look easy to maintain. Nevertheless, while I make an attempt to keep these typings in sync with the CheckboxTree PropTypes , I may sometimes forget, as was the case forid
. Ideally, there would be something that would automatically test these typings or automatically generate them in order to prevent this type of disconnect in the future so @djyako’s issue would not crop up again.Merged #169.