rusackas commented on code in PR #37107:
URL: https://github.com/apache/superset/pull/37107#discussion_r2728913149
##########
superset-frontend/src/components/Chart/ChartRenderer.tsx:
##########
@@ -17,55 +17,155 @@
* under the License.
*/
import { snakeCase, isEqual, cloneDeep } from 'lodash';
-import PropTypes from 'prop-types';
-import { createRef, Component } from 'react';
+import { createRef, Component, RefObject, MouseEvent, ReactNode } from 'react';
import {
SuperChart,
Behavior,
getChartMetadataRegistry,
VizType,
isFeatureEnabled,
FeatureFlag,
+ QueryFormData,
+ AnnotationData,
+ DataMask,
+ QueryData,
+ JsonObject,
+ LatestQueryFormData,
+ AgGridChartState,
+ ContextMenuFilters,
+ DataRecordFilters,
} from '@superset-ui/core';
import { logging } from '@apache-superset/core';
import { t } from '@apache-superset/core/ui';
import { Logger, LOG_ACTIONS_RENDER_CHART } from 'src/logger/LogUtils';
import { EmptyState } from '@superset-ui/core/components';
import { ChartSource } from 'src/types/ChartSource';
-import ChartContextMenu from './ChartContextMenu/ChartContextMenu';
-
-const propTypes = {
- annotationData: PropTypes.object,
- actions: PropTypes.object,
- chartId: PropTypes.number.isRequired,
- datasource: PropTypes.object,
- initialValues: PropTypes.object,
- formData: PropTypes.object.isRequired,
- latestQueryFormData: PropTypes.object,
- labelsColor: PropTypes.object,
- labelsColorMap: PropTypes.object,
- height: PropTypes.number,
- width: PropTypes.number,
- setControlValue: PropTypes.func,
- vizType: PropTypes.string.isRequired,
- triggerRender: PropTypes.bool,
- // state
- chartAlert: PropTypes.string,
- chartStatus: PropTypes.string,
- queriesResponse: PropTypes.arrayOf(PropTypes.object),
- triggerQuery: PropTypes.bool,
- chartIsStale: PropTypes.bool,
- // dashboard callbacks
- addFilter: PropTypes.func,
- setDataMask: PropTypes.func,
- onFilterMenuOpen: PropTypes.func,
- onFilterMenuClose: PropTypes.func,
- ownState: PropTypes.object,
- postTransformProps: PropTypes.func,
- source: PropTypes.oneOf([ChartSource.Dashboard, ChartSource.Explore]),
- emitCrossFilters: PropTypes.bool,
- onChartStateChange: PropTypes.func,
-};
+import type { Datasource, ChartStatus } from 'src/explore/types';
+import type { Dispatch } from 'redux';
+import ChartContextMenu, {
+ ChartContextMenuRef,
+} from './ChartContextMenu/ChartContextMenu';
+
+// Types for filter values
+type FilterValue = string | number | boolean | null | undefined;
+
+// LegendState type based on ECharts
+interface LegendState {
+ [name: string]: boolean;
+}
+
+// Webpack globals declaration
+declare const __webpack_require__:
+ | {
+ h?: () => string;
+ }
+ | undefined;
Review Comment:
Yes, this is necessary for TypeScript. The code at line 321+ uses
`__webpack_require__` to detect hot reloading:
```typescript
typeof __webpack_require__ !== 'undefined' &&
typeof __webpack_require__.h === 'function' &&
__webpack_require__.h()
```
Without this declaration, TypeScript errors on the undeclared global. The
declaration just tells TypeScript this global exists at runtime.
--
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]