Skip to content

Commit 0468ccd

Browse files
committed
rewrite JS to TS
1 parent 3bf00a4 commit 0468ccd

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

src/backend/linkFiber.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import 'core-js';
3636

3737
// const Tree = require('./tree').default;
3838
// const componentActionsRecord = require('./masterState');
39-
import { useGotoRecoilSnapshot, RecoilRoot, useRecoilSnapshot } from 'recoil';
4039
import {
4140
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4241
Snapshot,
@@ -48,7 +47,6 @@ import {
4847
import Tree from './tree';
4948
import componentActionsRecord from './masterState';
5049
import { throttle, getHooksNames } from './helpers';
51-
import ReactDOM from 'react-dom';
5250

5351
declare global {
5452
interface Window {
@@ -166,8 +164,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
166164
// });
167165
atomArray.push(memoizedProps);
168166

169-
// console.log('1st ATOM ARRAY', atomArray);
170-
171167
function traverseRecoilHooks(memoizedState: any): HookStates {
172168
const hooksStates: HookStates = [];
173169
while (memoizedState && memoizedState.queue) {
@@ -200,7 +196,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
200196
// so we must traverse through the list and get the states.
201197
// We then store them along with the corresponding memoizedState.queue,
202198
// which includes the dispatch() function we use to change their state.
203-
204199
const hooksStates = traverseRecoilHooks(memoizedState);
205200
const hooksNames = getHooksNames(elementType.toString());
206201
hooksStates.forEach((state, i) => {
@@ -333,8 +328,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
333328
const reactInstance = devTools ? devTools.renderers.get(1) : null;
334329
fiberRoot = devTools.getFiberRoots(1).values().next().value;
335330

336-
// console.log('FIBER ROOT', fiberRoot.current);
337-
338331
const throttledUpdateSnapshot = throttle(updateSnapShotTree, 70);
339332
document.addEventListener('visibilitychange', onVisibilityChange);
340333
if (reactInstance && reactInstance.version) {

src/backend/masterState.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import 'core-js';
33
/* eslint-disable no-plusplus */
44
/* eslint-disable guard-for-in */
55
/* eslint-disable no-restricted-syntax */
6-
76
const componentActionsRecord = {};
87
let index = 0;
98

10-
// module.exports = {
119
export default {
1210
saveNew: (state, component) => {
1311
componentActionsRecord[index] = { state, component };

src/backend/masterState.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2+
import 'core-js';
3+
/* eslint-disable no-plusplus */
4+
/* eslint-disable guard-for-in */
5+
/* eslint-disable no-restricted-syntax */
6+
const componentActionsRecord = {};
7+
let index = 0;
8+
9+
export default {
10+
saveNew: (state, component) => {
11+
componentActionsRecord[index] = { state, component };
12+
index++;
13+
return index - 1;
14+
},
15+
getRecordByIndex: inputIndex => componentActionsRecord[inputIndex],
16+
getComponentByIndex: inputIndex => (componentActionsRecord[inputIndex]
17+
? componentActionsRecord[inputIndex].component
18+
: undefined),
19+
};
20+
21+
class twoHaha {
22+
private componenActionsRecord : Array<any>;
23+
private index = 0;
24+
}

src/backend/recoilidea.js

Whitespace-only changes.

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"module": "es6",
55
"target": "es5",
66
"jsx": "react",
7+
"removeComments": true,
78
"allowJs": true,
89
"typeRoots": [
910
"./node_modules/@types"

0 commit comments

Comments
 (0)