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.

Support Typescript + React

See original GitHub issue

This doesn’t appear to work in a Typescript project using React. If I use the lower case <wired-button>, Typescript gives the error, Property 'wired-button' does not exist on type 'JSX.IntrinsicElements'. If I use <WiredButton> as if it were a React component, I get a runtime error, TypeError: Class constructor WiredButton cannot be invoked without 'new'. Is there any way to fix one/both of these errors, or modify the library so it can be used in Typescript + React projects?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
b7s9commented, Jan 17, 2021

I’m getting this same error in 2021. Next.js + Typescript environment

0reactions
alexandrtovmachcommented, Dec 9, 2022

Have successful setup of wired elements in react + ts project. What I did:

  1. Install elements from npm (+ roughjs package #179 ):
    npm i wired-elements roughjs@4.4
    
  2. Create src/wired.d.ts to have proper typings:
    type Wired2React<T> = Partial<T> & React.RefAttributes<T> | React.HTMLAttributes<T>;
    declare namespace JSX {
      interface IntrinsicElements {
        "wired-button": Wired2React<import("wired-elements").WiredButton>;
        "wired-calendar": Wired2React<import("wired-elements").WiredCalendar>;
        "wired-card": Wired2React<import("wired-elements").WiredCard>;
        "wired-checkbox": Wired2React<import("wired-elements").WiredCheckbox>;
        "wired-combo": Wired2React<import("wired-elements").WiredCombo>;
        "wired-dialog": Wired2React<import("wired-elements").WiredDialog>;
        "wired-divider": Wired2React<import("wired-elements").WiredDivider>;
        "wired-fab": Wired2React<import("wired-elements").WiredFab>;
        "wired-icon-button": Wired2React<import("wired-elements").WiredIconButton>;
        "wired-image": Wired2React<import("wired-elements").WiredImage>;
        "wired-input": Wired2React<import("wired-elements").WiredInput>;
        "wired-item": Wired2React<import("wired-elements").WiredItem>;
        "wired-link": Wired2React<import("wired-elements").WiredLink>;
        "wired-listbox": Wired2React<import("wired-elements").WiredListbox>;
        "wired-progress": Wired2React<import("wired-elements").WiredProgress>;
        "wired-radio": Wired2React<import("wired-elements").WiredRadio>;
        "wired-search-input": Wired2React<import("wired-elements").WiredSearchInput>;
        "wired-slider": Wired2React<import("wired-elements").WiredSlider>
        "wired-spinner": Wired2React<import("wired-elements").WiredSpinner>;
        "wired-tabs": Wired2React<import("wired-elements").WiredTabs>;
        "wired-textarea": Wired2React<import("wired-elements").WiredTextarea>;
        "wired-toggle": Wired2React<import("wired-elements").WiredToggle>;
        "wired-video": Wired2React<import("wired-elements").WiredVideo>;
      }
    }
    
Read more comments on GitHub >

github_iconTop Results From Across the Web

React - TypeScript: Documentation
TypeScript supports JSX and can correctly model the patterns used in React codebases like useState . Getting Set Up With a React Project....
Read more >
Static Type Checking - React
Static type checkers like Flow and TypeScript identify certain types of problems before you even run your code. They can also improve developer...
Read more >
How to use TypeScript with React: A tutorial with examples
Support for existing React projects ... TypeScript allows you gradually adapt its usage in your existing projects. You can also configure the ...
Read more >
Adding TypeScript - Create React App
Global installs of create-react-app are no longer supported. To add TypeScript to an existing Create React App project, first install it: npm ...
Read more >
Using TypeScript with React - DigitalOcean
This tutorial covers how to use TypeScript with React functional or ... First, install the React dependencies react and react-dom :.
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