@@ -8,6 +8,7 @@ import SwitchAppDropdown from '../components/SwitchApp';
88import { emptySnapshots , changeView , changeSlider } from '../actions/actions' ;
99import { useStoreContext } from '../store' ;
1010import RouteDescription from '../components/RouteDescription' ;
11+ import { Obj } from '../components/FrontendTypes' ;
1112
1213const resetSlider = ( ) => {
1314 const slider = document . querySelector ( '.rc-slider-handle' ) ;
@@ -22,20 +23,11 @@ function ActionContainer(props): JSX.Element {
2223 const { toggleActionContainer, actionView, setActionView } = props ;
2324 const [ recordingActions , setRecordingActions ] = useState ( true ) ;
2425
25- let actionsArr = [ ] ;
26- const hierarchyArr : any [ ] = [ ] ;
26+ let actionsArr : JSX . Element [ ] = [ ] ;
27+ const hierarchyArr : ( number | { } ) [ ] = [ ] ;
2728
2829 // function to traverse state from hierarchy and also getting information on display name and component name
29- const displayArray = ( obj : {
30- stateSnapshot : {
31- route : any ;
32- children : any [ ] ;
33- } ;
34- name : number ;
35- branch : number ;
36- index : number ;
37- children ?: [ ] ;
38- } ) => {
30+ const displayArray = ( obj : Obj ) : void => {
3931 if (
4032 obj . stateSnapshot . children . length > 0 &&
4133 obj . stateSnapshot . children [ 0 ] &&
@@ -56,7 +48,7 @@ function ActionContainer(props): JSX.Element {
5648 hierarchyArr . push ( newObj ) ;
5749 }
5850 if ( obj . children ) {
59- obj . children . forEach ( ( element ) => {
51+ obj . children . forEach ( ( element ) : void => {
6052 displayArray ( element ) ;
6153 } ) ;
6254 }
@@ -67,7 +59,7 @@ function ActionContainer(props): JSX.Element {
6759 if ( hierarchy ) displayArray ( hierarchy ) ;
6860
6961 // handles keyboard presses, function passes an event and index of each action-component
70- function handleOnKeyDown ( e : KeyboardEvent , i : number ) {
62+ function handleOnKeyDown ( e : KeyboardEvent , i : number ) : void {
7163 let currIndex = i ;
7264 // up arrow key pressed
7365 if ( e . key === 'ArrowUp' ) {
@@ -89,7 +81,9 @@ function ActionContainer(props): JSX.Element {
8981 }
9082 }
9183 // Sort by index.
92- hierarchyArr . sort ( ( a , b ) => a . index - b . index ) ;
84+
85+ hierarchyArr . sort ( ( a :Obj , b :Obj ) :number => a . index - b . index ) ;
86+
9387 actionsArr = hierarchyArr . map (
9488 ( snapshot : {
9589 routePath : any ;
@@ -128,7 +122,7 @@ function ActionContainer(props): JSX.Element {
128122 } , [ setActionView ] ) ;
129123
130124 // Function sends message to background.js which sends message to the content script
131- const toggleRecord = ( ) => {
125+ const toggleRecord = ( ) : void => {
132126 port . postMessage ( {
133127 action : 'toggleRecord' ,
134128 tabId : currentTab ,
@@ -142,7 +136,7 @@ function ActionContainer(props): JSX.Element {
142136 [ route : string ] : [ ] ;
143137 } ;
144138
145- const routes = { } ;
139+ const routes : { } = { } ;
146140 for ( let i = 0 ; i < actionsArr . length ; i += 1 ) {
147141 if ( ! routes . hasOwnProperty ( actionsArr [ i ] . props . routePath ) ) {
148142 routes [ actionsArr [ i ] . props . routePath ] = [ actionsArr [ i ] ] ;
0 commit comments