Closed
Description
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);