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

Example of usage meteor/react-meteor-data with withRouter in typescript #368

Open
gustawdaniel opened this issue Nov 3, 2022 · 0 comments

Comments

@gustawdaniel
Copy link

gustawdaniel commented Nov 3, 2022

I am using this package with typescript

https://packosphere.com/meteor/react-meteor-data

My code

import React from 'react';
// import {withRouter} from 'react-router-dom';
import {withTracker} from 'meteor/react-meteor-data';
import {RouteComponentProps, withRouter} from 'react-router-dom';

interface IProps extends RouteComponentProps<any> {
	title: string;
}

class MyComp extends React.Component<IProps> {
	public render(): JSX.Element {
		return <h1>{this.props.title}</h1>;
	}
}

export default withRouter<IProps, typeof MyComp>(
	withTracker(() => {
		return {title: 'ok'};
	})(MyComp)
);

Error:

2022-11-03_19-06

Description

TS2345: Argument of type 'ComponentClass<unknown, any>' is not assignable to parameter of type 'typeof MyComp & ComponentType<IProps>'.
Type 'ComponentClass<unknown, any>' is not assignable to type 'typeof MyComp & ComponentClass<IProps, any>'.
Type 'ComponentClass<unknown, any>' is not assignable to type 'typeof MyComp'.
Construct signature return types 'Component<unknown, any, any>' and 'MyComp' are incompatible.
The types returned by 'render()' are incompatible between these types.
Type 'ReactNode' is not assignable to type 'Element'.
Type 'undefined' is not assignable to type 'ReactElement<any, any>'.

@gustawdaniel gustawdaniel changed the title TS2345: Argument of type 'ComponentClass&lt;unknown, any&gt;' is not assignable to parameter of type 'typeof MyComp &amp; ComponentType&lt;IProps&gt;'.<br/>Type 'ComponentClass&lt;unknown, any&gt;' is not assignable to type 'typeof MyComp &amp; ComponentClass&lt;IProps, any&gt;'.<br/>Type 'ComponentClass&lt;unknown, any&gt;' is not assignable to type 'typeof MyComp'.<br/>Construct signature return types 'Component&lt;unknown, any, any&gt;' and 'MyComp' are incompatible.<br/>The types returned by 'render()' are incompatible between these types.<br/>Type 'ReactNode' is not assignable to type 'Element'.<br/>Type 'undefined' is not assignable to type 'ReactElement&lt;any, any&gt;'. Example of usage meteor/react-meteor-data with withRouter in typescript Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant