Skip to content

Commit 642de32

Browse files
Samuel  TranSamuel  Tran
authored andcommitted
Added event typing for importHandler function. Changed import tutorial from tutorial.tsx file to require
Changing import tutorial to require from tutorial.tsx file allows TS compatibility because it change the type of tutorial class to any which is what was the problem before. Left comments inside to aid next iterator to fix this error
1 parent 4b0e821 commit 642de32

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/app/components/Tutorial.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
99
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
1010
import { tutorialSaveSeriesToggle, setCurrentTabInApp } from '../actions/actions';
1111

12+
//Must be required in. This enables compatibility with TS. If imported in, throws ts error of not rendering steps as a class component correctly.
1213
const { Steps } = require('intro.js-react');
1314

1415
interface tutorialProps {

src/app/containers/ButtonsContainer.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-nocheck
2-
31
import * as React from 'react';
42
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
53
import {
@@ -12,7 +10,8 @@ import {
1210
} from '@fortawesome/free-solid-svg-icons';
1311
import { importSnapshots, toggleMode, toggleSplit } from '../actions/actions';
1412
import { useStoreContext } from '../store';
15-
import Tutorial from '../components/Tutorial';
13+
14+
const Tutorial = require('../components/Tutorial');
1615

1716
function exportHandler(snapshots: []) {
1817
// create invisible download anchor link
@@ -35,15 +34,18 @@ function importHandler(dispatch: (a: unknown) => void) {
3534
const fileUpload = document.createElement('input');
3635
fileUpload.setAttribute('type', 'file');
3736

38-
fileUpload.onchange = (e) => {
37+
fileUpload.onchange = (e: Event) => {
3938
const reader = new FileReader();
4039
reader.onload = () => {
4140
const test = reader.result.toString();
4241
return dispatch(importSnapshots(JSON.parse(test)));
4342
};
44-
if (e.target.hasOwnProperty('files')) {
45-
const eventFiles: unknown = e.target;
46-
reader.readAsText(eventFiles.files[0]);
43+
const eventFiles = e.target as HTMLInputElement;
44+
if (eventFiles?.hasOwnProperty('files')) {
45+
// const eventFiles = target as HTMLInputElement;
46+
if (eventFiles) {
47+
reader.readAsText(eventFiles.files[0]);
48+
}
4749
}
4850
};
4951

0 commit comments

Comments
 (0)