Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript decorator typing errors for custom params on a class component #74

Closed
OscarBarrett opened this issue Jul 9, 2019 · 4 comments
Labels

Comments

@OscarBarrett
Copy link

When using the @themr decorator on a React class component, if there are custom parameters (such as a parameter holding a ref) then Typescript gives the following error:

Unable to resolve signature of class decorator when called as an expression.
  Type 'ThemedComponentClass<{ mapThemrProps?: TMapThemrProps<{}>; }, {}>' is not assignable to type 'typeof App'.
    Property 'myRef' is missing in type 'ThemedComponent<{ mapThemrProps?: TMapThemrProps<{}>; }, {}>' but required in type 'App'.ts(1238)

Simple example here: https://codesandbox.io/s/flamboyant-wiles-bu7m3

import * as React from "react";
import { render } from "react-dom";
import { themr } from "@friendsofreactjs/react-css-themr";

const styles = require("./styles.css");

@themr("App", styles)
export default class App extends React.Component {
  myRef: any = React.createRef();

  render() {
    return (
      <div className="foo" ref={this.myRef}>
        Foo
      </div>
    );
  }
}

const rootElement = document.getElementById("root");
render(<App />, rootElement);
@markusguenther
Copy link
Member

Thanks for reporting that. ❤️

markusguenther added a commit that referenced this issue Jul 22, 2020
We now having the tpe definitions as extra types folder instead of the single index.d.ts file.

re #74
@markusguenther
Copy link
Member

🎉 This issue has been resolved in version 4.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markusguenther
Copy link
Member

Sorry I made a mistake ... it worked locally but the released version has the same issue :(
Sorry for that.

@markusguenther
Copy link
Member

https://codesandbox.io/s/reverent-bogdan-9jnce?file=/src/index.tsx

Now i have it ... again sorry for the inconveniences. Hope that it helps and thanks again for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants