Skip to content

Commit 7c793b0

Browse files
committed
updated typescript in componentMap, LinkControls, and BarGraphComparison.tsx parameter
1 parent f1c71bb commit 7c793b0

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
/* eslint-disable react/no-array-index-key */
2+
/* eslint-disable react/prop-types */
13
/* eslint-disable jsx-a11y/click-events-have-key-events */
24
/* eslint-disable no-nested-ternary */
35
/* eslint-disable no-unused-expressions */
46
/* eslint-disable jsx-a11y/no-static-element-interactions */
57
/* eslint-disable no-restricted-syntax */
68
/* eslint-disable guard-for-in */
7-
// @ts-nocheck
9+
810
import React, { useState, useEffect } from 'react';
911
import { Group } from '@visx/group';
1012
import { hierarchy, Tree } from '@visx/hierarchy';
@@ -32,6 +34,7 @@ export type LinkTypesProps = {
3234
height: number;
3335
margin?: { top: number; right: number; bottom: number; left: number };
3436
snapshots: Record<string, unknown>;
37+
currentSnapshot?: Record<string, unknown>
3538
};
3639

3740
export default function ComponentMap({
@@ -55,8 +58,8 @@ export default function ComponentMap({
5558
}, [dispatch]);
5659

5760
// setting the margins for the Map to render in the tab window.
58-
const innerWidth = totalWidth - margin.left - margin.right;
59-
const innerHeight = totalHeight - margin.top - margin.bottom - 60;
61+
const innerWidth: number = totalWidth - margin.left - margin.right;
62+
const innerHeight: number = totalHeight - margin.top - margin.bottom - 60;
6063

6164
let origin: { x: number; y: number };
6265
let sizeWidth: number;
@@ -122,9 +125,9 @@ export default function ComponentMap({
122125
overflowWrap: 'break-word',
123126
};
124127

125-
const formatRenderTime = time => {
126-
time = time.toFixed(3);
127-
return `${time} ms `;
128+
const formatRenderTime = (time: number): string => {
129+
const renderTime = time.toFixed(3);
130+
return `${renderTime} ms `;
128131
};
129132

130133
const formatProps = data => {
@@ -172,7 +175,7 @@ export default function ComponentMap({
172175
collectNodes(currentSnapshot);
173176

174177
// find the node that has been selected and use it as the root
175-
const startNode = null;
178+
let startNode = null;
176179
let rootNode;
177180
const findSelectedNode = () => {
178181
for (const node of nodeList) {
@@ -215,7 +218,7 @@ export default function ComponentMap({
215218
/>
216219
<Group top={margin.top} left={margin.left}>
217220
<Tree
218-
root={hierarchy(startNode || data, d => (d.isExpanded ? d.children : null))}
221+
root={hierarchy(startNode, d => (d.isExpanded ? d.children : null))}
219222
size={[sizeWidth, sizeHeight]}
220223
separation={(a, b) => (a.parent === b.parent ? 1 : 0.5) / a.depth}
221224
>
@@ -332,7 +335,6 @@ export default function ComponentMap({
332335
? 'white'
333336
: '#161521'
334337
}
335-
z
336338
>
337339
{node.data.name}
338340
</text>
@@ -374,7 +376,7 @@ export default function ComponentMap({
374376
State:
375377
{formatState(tooltipData.state)}
376378
</div>
377-
<div style={scrollStyle}>
379+
<div style={React.scrollStyle}>
378380
<div className="props">
379381
Props:
380382
{formatProps(tooltipData.componentData.props)}

src/app/components/StateRoute/ComponentMap/LinkControls.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jsx-a11y/label-has-associated-control */
12
import React from 'react';
23
// Font size of the Controls label and Dropdowns
34
const controlStyles = {
@@ -28,10 +29,10 @@ type Props = {
2829
setLinkType: (linkType: string) => void;
2930
setStepPercent: (percent: number) => void;
3031
setSelectedNode: (selectedNode: string) => void;
31-
snapShots: [];
32+
snapShots: Record<string, unknown>;
3233
};
3334

34-
//use BFS to put all the nodes under snapShots(which is the tree node) into an array
35+
// use BFS to put all the nodes under snapShots(which is the tree node) into an array
3536
const nodeList = [];
3637

3738
const collectNodes = node => {
@@ -41,10 +42,8 @@ const collectNodes = node => {
4142
nodeList.push(node);
4243
for (let i = 0; i < nodeList.length; i += 1) {
4344
const cur = nodeList[i];
44-
if (cur.children && cur.children.length > 0) {
45-
for (let child of cur.children) {
46-
nodeList.push(child);
47-
}
45+
if (cur.children?.length > 0) {
46+
cur.children.forEach(child => nodeList.push(child));
4847
}
4948
}
5049
};
@@ -59,15 +58,17 @@ export default function LinkControls({
5958
setStepPercent,
6059
setSelectedNode,
6160
snapShots,
62-
}: Props) {
61+
}: Props): JSX.Element {
6362
collectNodes(snapShots);
6463

6564
return (
6665
<div style={controlStyles}>
6766

6867
{/* Controls for the layout selection */}
6968
<label>Layout:</label>
70-
&nbsp; {/*This is a non-breaking space - Prevents an automatic line break at this position */}
69+
&nbsp;
70+
{' '}
71+
{/* This is a non-breaking space - Prevents an automatic line break at this position */}
7172
<select
7273
onClick={e => e.stopPropagation()}
7374
onChange={e => setLayout(e.target.value)}
@@ -108,12 +109,16 @@ export default function LinkControls({
108109

109110
{/* Controls for the select selections. */}
110111
<label> Select:</label>
111-
&nbsp;
112-
<input id='selectInput' list='nodeOptions' type='text' name="nodeOptions"
112+
&nbsp;
113+
<input
114+
id="selectInput"
115+
list="nodeOptions"
116+
type="text"
117+
name="nodeOptions"
113118
onChange={e => setSelectedNode(e.target.value)}
114119
style={dropDownStyle}
115120
/>
116-
<datalist id='nodeOptions'>
121+
<datalist id="nodeOptions">
117122
{nodeList.map(node => (
118123
<option key={node.name} value={node.name}>{node.name}</option>
119124
))}

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
202202
for (let i = 0; i < classname.length; i += 1) {
203203
classname[i].addEventListener('click', animateButton, false);
204204
}
205-
const seriesList: ActionObj[][] = comparison.map((series: Series) => series.data.barStack);
205+
const seriesList: ActionObj[][] = comparison.map((action: Series) => action.data.barStack);
206206
const actionsList: ActionObj[] = seriesList.flat();
207207
const testList: string[] = actionsList.map((elem: ActionObj) => elem.name);
208208

0 commit comments

Comments
 (0)