rusackas commented on code in PR #37625:
URL: https://github.com/apache/superset/pull/37625#discussion_r2770062865


##########
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx:
##########
@@ -157,58 +223,76 @@ function convertToArray(
   return result;
 }
 
-export class TableRenderer extends Component {
-  constructor(props) {
+export class TableRenderer extends Component<
+  TableRendererProps,
+  TableRendererState
+> {
+  sortCache: Map<string, string[][]>;
+  cachedProps: TableRendererProps | null;
+  cachedBasePivotSettings: PivotSettings | null;
+
+  static propTypes: Record<string, unknown>;
+  static defaultProps: Record<string, unknown>;
+
+  constructor(props: TableRendererProps) {
     super(props);
 
     // We need state to record which entries are collapsed and which aren't.
     // This is an object with flat-keys indicating if the corresponding rows
     // should be collapsed.
     this.state = { collapsedRows: {}, collapsedCols: {}, sortingOrder: [] };
     this.sortCache = new Map();
+    this.cachedProps = null;
+    this.cachedBasePivotSettings = null;
     this.clickHeaderHandler = this.clickHeaderHandler.bind(this);
     this.clickHandler = this.clickHandler.bind(this);
   }
 
-  getBasePivotSettings() {
+  getBasePivotSettings(): PivotSettings {
     // One-time extraction of pivot settings that we'll use throughout the 
render.
 
     const { props } = this;
     const colAttrs = props.cols;
     const rowAttrs = props.rows;
 
-    const tableOptions = {
+    const tableOptions: Record<string, unknown> = {
       rowTotals: true,
       colTotals: true,
       ...props.tableOptions,
     };
-    const rowTotals = tableOptions.rowTotals || colAttrs.length === 0;
-    const colTotals = tableOptions.colTotals || rowAttrs.length === 0;
+    const rowTotals =
+      (tableOptions.rowTotals as boolean) || colAttrs.length === 0;
+    const colTotals =
+      (tableOptions.colTotals as boolean) || rowAttrs.length === 0;

Review Comment:
   ~~Agreed — defining a `TableOptions` interface would eliminate these casts. 
This is pre-existing untyped code from the JS era; the TS migration preserves 
existing behavior with casts rather than redesigning interfaces. I'll file a 
follow-up issue to type `tableOptions` / `subtotalOptions` properly.~~
   
   Actually, I'll just tackle this...



-- 
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]

Reply via email to