Skip to content

Commit 28c1394

Browse files
authored
Merge pull request #17 from oslabs-beta/samtran/feature
Samtran/feature
2 parents f1c71bb + 344aa51 commit 28c1394

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

src/app/components/Tutorial.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/* eslint-disable react/sort-comp */
22
/* eslint-disable lines-between-class-members */
33
/* eslint-disable react/static-property-placement */
4-
//@ts-nocheck
4+
55
import * as React from 'react';
66
import { Component } from 'react';
7-
import { Steps } from 'intro.js-react';
87
import 'intro.js/introjs.css';
98
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
109
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
1110
import { tutorialSaveSeriesToggle, setCurrentTabInApp } from '../actions/actions';
1211

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.
13+
const { Steps } = require('intro.js-react');
14+
1315
interface tutorialProps {
1416
dispatch: (object) => void;
1517
currentTabInApp: string;
@@ -22,14 +24,21 @@ interface tutorialState {
2224
// This is the tutorial displayed when the "How to use" button is clicked
2325
// This needs to be a class component to be compatible with updateStepElement from intro.js
2426
export default class Tutorial extends React.Component<tutorialProps, tutorialState> {
25-
constructor(props:tutorialProps) {
27+
constructor(props: tutorialProps) {
2628
super(props);
2729
this.state = {
2830
stepsEnabled: false,
2931
};
3032
}
3133

32-
public props: tutorialProps;
34+
//tutorial class needs these public variables to be a valid class component for ts when rendered in buttonscontainer.tsx
35+
public context: any;
36+
public setState: any;
37+
public forceUpdate: any;
38+
public props: any;
39+
public state: any;
40+
public refs: any;
41+
3342
render(): JSX.Element {
3443
const { currentTabInApp, dispatch } = this.props;
3544

src/app/containers/ButtonsContainer.tsx

Lines changed: 8 additions & 6 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,6 +10,7 @@ import {
1210
} from '@fortawesome/free-solid-svg-icons';
1311
import { importSnapshots, toggleMode, toggleSplit } from '../actions/actions';
1412
import { useStoreContext } from '../store';
13+
1514
import Tutorial from '../components/Tutorial';
1615

1716
function exportHandler(snapshots: []) {
@@ -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

src/app/containers/MainContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* eslint-disable max-len */
2-
// @ts-nocheck
32
import React, { useEffect, useState } from 'react';
4-
import Split from 'react-split';
53
import ActionContainer from './ActionContainer';
64
import TravelContainer from './TravelContainer';
75
import ButtonsContainer from './ButtonsContainer';
@@ -19,6 +17,9 @@ import {
1917
} from '../actions/actions';
2018
import { useStoreContext } from '../store';
2119

20+
//Must be required in. This enables compatibility with TS. If imported in, throws ts error of not rendering steps as a class component correctly.
21+
const Split = require('react-split');
22+
2223
function MainContainer(): JSX.Element {
2324
const [store, dispatch] = useStoreContext();
2425
const {

src/backend/__tests__/linkFiber.test.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
/* eslint-disable import/order */
77
/* eslint-disable import/no-extraneous-dependencies */
88
/* eslint-disable react/jsx-filename-extension */
9-
//@ts-nocheck
10-
import React, { Component } from 'react';
9+
import { string } from 'prop-types';
10+
import React, { useState } from 'react';
1111
import { render } from 'react-dom';
1212
import linkFiberStart from '../linkFiber';
1313

@@ -24,17 +24,17 @@ let snapShot;
2424
let browser;
2525
let page;
2626

27-
class App extends Component{
28-
state: { foo: string; };
29-
constructor(props) {
30-
super(props);
31-
this.state = { foo: 'bar' };
32-
}
33-
34-
render() {
35-
const { foo } = this.state;
36-
return <div>{foo}</div>;
37-
}
27+
interface fooState {
28+
foo: string,
29+
setFoo?: (string) => void
30+
}
31+
function App(): JSX.Element {
32+
const [fooState, setFooState] = useState({
33+
foo: 'bar',
34+
});
35+
return (
36+
<div>{fooState}</div>
37+
);
3838
}
3939

4040
xdescribe('unit test for linkFiber', () => {

0 commit comments

Comments
 (0)