aminghadersohi commented on code in PR #39458:
URL: https://github.com/apache/superset/pull/39458#discussion_r3383224267
##########
superset-frontend/packages/superset-ui-core/src/chart/components/reactify.tsx:
##########
@@ -49,66 +61,102 @@ export interface RenderFuncType<Props> {
propTypes?: WeakValidationMap<Props & ReactifyProps>;
}
+export interface ReactifiedComponentRef {
+ container?: HTMLDivElement;
+}
+
+export type ReactifiedComponent<Props> = ForwardRefExoticComponent<
+ PropsWithoutRef<Props & ReactifyProps> &
RefAttributes<ReactifiedComponentRef>
+>;
+
+// Return the widest public type that covers "use it as a React component" so
+// TypeScript consumers who previously relied on `ComponentClass<...>` still
+// compile. Callers that want the new ref-aware surface can narrow to
+// `ReactifiedComponent<Props>` explicitly.
Review Comment:
The comment overstates backward compatibility: `ComponentType<P>` is not
assignable to `ComponentClass<P>`, so callers with `const Chart:
ComponentClass<...> = reactify(fn)` still fail TypeScript after this change.
Only JSX callers and `ComponentType<...>`-typed variables remain compatible.
```suggestion
// Return the widest public type that covers "use it as a React component" so
// TypeScript JSX callers and `ComponentType<...>`-typed variables still
compile;
// callers with explicit `ComponentClass<...>` annotations must widen to
// `ComponentType`. Those wanting the forwardRef surface can narrow to
// `ReactifiedComponent<Props>` explicitly.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]