-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Change in generic behaviors since 3.1.6 and 3.2.0-rc #28646
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
Comments
Something looks weird. Why does the error message not include the possible |
|
It can be resolved like so: export interface IAnalyticsProps {
analyticsContext?: IAnalyticsContext;
}
export default function withAnalytics<
Props extends IAnalyticsProps,
ComponentProps = Omit<Props, "analyticsContext">
>(
Component: React.ComponentClass<Props> | React.SFC<Props>
): React.SFC<ComponentProps> {
return function AnalyticsContextBoundComponent(
props: Props & ComponentProps
) {
return (
<AnalyticsContextConsumer>
{value => <Component {...props} analyticsContext={value} />}
</AnalyticsContextConsumer>
);
};
} |
I just stumbled upon the same issue.
Thanks for the workaround!
If I will not define export default function withAnalytics<
Props extends {
analyticsContext?: IAnalyticsContext;
}
>(
Component: React.ComponentClass<Props> | React.SFC<Props>
): React.SFC<Omit<Props, "analyticsContext">> {
return function AnalyticsContextBoundComponent(props: Omit<Props, "analyticsContext">) {
return (
<AnalyticsContextConsumer>
{value => <Component {...props} analyticsContext={value} />}
</AnalyticsContextConsumer>
);
};
} The error is basically the same:
|
TypeScript Version: 3.2.0-rc
Search Terms: react hoc 3.2.0-rc not assignable to
Code
Expected behavior:
This way of creating HOC worked without any problems in TypeScript 3.1.6, but I noticed the error in VSCode TypeScript version (3.2.0-rc), so I am wondering what is changed since this is now not a working example anymore.
Actual behavior:
Possible related issues:
#27895
The text was updated successfully, but these errors were encountered: