question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there Typescript support?

See original GitHub issue

I 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.

image

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:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jakezateckycommented, May 24, 2019

@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 and JSX.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 what PropTypes.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 for id. 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.

0reactions
jakezateckycommented, Oct 9, 2019

Merged #169.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >
TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >
TypeScript Programming with Visual Studio Code
No, the TypeScript language service that ships with Visual Studio 2019 and 2022 isn't compatible with VS Code. You will need to install...
Read more >
TypeScript support in Svelte - Learn web development
The goal of TypeScript is to help catch mistakes early through its type system and make JavaScript development more efficient.
Read more >
TypeScript | IntelliJ IDEA Documentation - JetBrains
Javascript and TypeScript - The plugin is available only in IntelliJ IDEA Ultimate, where it is enabled by default. IntelliJ IDEA supports ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found