Skip to content

Commit c0ea64b

Browse files
committed
add typescript to ComponentMap and History
1 parent c5b4ef3 commit c0ea64b

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,29 @@
44
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
55
/* eslint-disable @typescript-eslint/ban-types */
66

7-
import React, { useEffect, useCallback, useState } from 'react';
7+
import React, { useEffect, useCallback } from 'react';
88
import * as d3 from 'd3';
99

10-
const ComponentMap = (props) => {
10+
interface componentMapProps {
11+
x: number;
12+
y: number;
13+
k: number;
14+
setZoomState: any;
15+
snapshots: [];
16+
viewIndex: number;
17+
}
18+
19+
const ComponentMap = (props: componentMapProps) => {
1120
//import props
12-
const { viewIndex, snapshots ,x ,y, k, setZoomState} = props;
21+
const { viewIndex, snapshots ,x , y, k, setZoomState} = props;
1322
let lastSnap: number | null = null;
1423
if (viewIndex < 0) lastSnap = snapshots.length - 1;
1524
else lastSnap = viewIndex;
1625

1726
//external constants
1827
const width: number = 900;
1928
const height: number = 600;
20-
let data = snapshots[lastSnap];
29+
let data: Object = snapshots[lastSnap];
2130

2231
useEffect(() => {
2332
document.getElementById('canvas').innerHTML = '_';

src/app/components/History.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class History extends Component {
7474
maked3Tree(): void {
7575
this.removed3Tree();
7676

77-
const width = 800;
78-
const height = 600;
77+
const width : number = 800;
78+
const height : number = 600;
7979
const svgContainer = d3
8080
.select(this.HistoryRef.current)
8181
.append('svg') // svgContainer is now pointing to svg

src/app/components/StateRoute.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ const History = require('./History').default;
1919

2020
const ErrorHandler = require('./ErrorHandler').default;
2121

22-
const NO_STATE_MSG =
23-
'No state change detected. Trigger an event to change state';
22+
const NO_STATE_MSG = 'No state change detected. Trigger an event to change state';
2423
// eslint-disable-next-line react/prop-types
2524

2625
interface StateRouteProps {
@@ -44,6 +43,7 @@ const StateRoute = (props: StateRouteProps) => {
4443
y: 250,
4544
k: 0.75,
4645
});
46+
4747
//Map
4848
const renderComponentMap = () => {
4949
if (hierarchy) {

0 commit comments

Comments
 (0)