Skip to content

Commit 666b850

Browse files
types to COmponentReducer.util
1 parent d8e92ef commit 666b850

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/utils/Interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ComponentInt {
3232
title: string;
3333
color: string;
3434
// draggable: boolean;
35-
props: Prop[];
35+
props: PropInt[];
3636
nextPropId: number;
3737
position: Position;
3838
childrenArray: ChildInt[];

src/utils/componentReducer.util.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "./interfaces";
1313

1414
const initialComponentState: ComponentInt = {
15-
id: null,
15+
id: 0,
1616
stateful: false,
1717
title: "",
1818
color: getColor(),
@@ -115,7 +115,7 @@ export const addChild = (
115115

116116
// view represents the curretn FOCUSED COMPONENT - this is the component where the child is being added to
117117
// we only add childrent (or do any action) to the focused omconent
118-
const view = state.components.find(
118+
const view : ComponentInt = state.components.find(
119119
comp => comp.title === state.focusComponent.title
120120
);
121121

@@ -389,7 +389,7 @@ export const changeFocusComponent = (
389389
// set the "focus child" to the focus child of this particular component .
390390
// const newFocusChildId = newFocusComp.focusChildId;
391391

392-
let newFocusChild; // check if the components has a child saved as a Focus child
392+
let newFocusChild: ChildInt|any; // check if the components has a child saved as a Focus child
393393
if (newFocusComp.focusChildId > 0) {
394394
newFocusChild = newFocusComp.childrenArray.find(
395395
child => child.childId === newFocusComp.focusChildId
@@ -517,7 +517,7 @@ export const addProp = (
517517
comp => comp.id === state.focusComponent.id
518518
);
519519

520-
const newProp = {
520+
const newProp:PropInt = {
521521
id: selectedComponent.nextPropId,
522522
key,
523523
value: value || key,
@@ -579,18 +579,19 @@ export const deleteProp = (state: ApplicationStateInt, propId: number) => {
579579
};
580580
};
581581

582-
export const updateHtmlAttr = (state, { attr, value }) => {
582+
export const updateHtmlAttr = (state: ApplicationStateInt, { attr, value }: {attr:string, value:string}) => {
583583
if (!state.focusChild.childId) {
584584
console.log("Update HTML error. no focused child ");
585585
return state;
586586
}
587587

588-
const modifiedChild = cloneDeep(state.focusChild);
588+
const modifiedChild:any = cloneDeep(state.focusChild);
589589
modifiedChild.HTMLInfo[attr] = value;
590590

591-
const modifiedComponent = cloneDeep(
592-
state.components.find(comp => comp.id === state.focusComponent.id)
593-
);
591+
// let modifiedComponent = cloneDeep(
592+
// state.components.find(comp => comp.id === state.focusComponent.id)
593+
// );
594+
let modifiedComponent: ComponentInt = JSON.parse(JSON.stringify(( state.components.find(comp => comp.id === state.focusComponent.id)))) ;
594595

595596
modifiedComponent.childrenArray = modifiedComponent.childrenArray.filter(
596597
child => child.childId !== modifiedChild.childId

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"module": "commonjs",
77
"target": "es6",
88
"jsx": "react",
9-
"strict": true,
10-
"alwaysStrict": true
9+
// "strict": true,
10+
// "alwaysStrict": true
1111
//these two options are recommended but don't work, maybe an issue with awesome-typsecript-loader vs babel
1212
// "esModuleInterop": true
1313
// "allowSyntheticDefaultImports": true

0 commit comments

Comments
 (0)