Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
went2 committed Jul 6, 2023
1 parent 343e447 commit 0618684
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/components/ColorSelect.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import elt from "../utils/createElement";
import { UIComponent, EditorState } from "../types";

class ColorSelect implements UIComponent {
public input: HTMLInputElement;
public dom: HTMLElement;
constructor(state: EditorState, { dispatch }) {
constructor(
state: EditorState,
{ dispatch }: { dispatch: (...args: any[]) => void }
) {
this.input = elt("input", {
type: "color",
value: state.color,
Expand Down
4 changes: 3 additions & 1 deletion src/components/LoadButton.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import elt from "../utils/createElement";
import { EditorConfig, UIComponent } from "../types";
import { startLoad } from "../utils/fileLoader";

class LoadButton implements UIComponent {
public dom: HTMLElement;
constructor(_, { dispatch }) {
constructor(_: any, { dispatch }: EditorConfig) {
this.dom = elt(
"button",
{
Expand Down
7 changes: 5 additions & 2 deletions src/components/SaveButton.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import elt from "../utils/createElement";
import { EditorState, UIComponent } from "../types";
import Picture from "../models/Picture";
import { drawPicture } from "../utils/drawHelpers";

class SaveButton implements UIComponent {
public picture: Picture;
public dom: HTMLElement;

constructor(state) {
constructor(state: EditorState) {
this.picture = state.picture;
this.dom = elt(
"button",
Expand All @@ -25,7 +28,7 @@ class SaveButton implements UIComponent {
link.click();
link.remove();
}
syncState(state) {
syncState(state: EditorState) {
this.picture = state.picture;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ToolSelect.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import elt from "../utils/createElement";
import { EditorConfig, EditorState, UIComponent } from "../types";

class ToolSelect implements UIComponent {
public select: HTMLSelectElement;
public dom: HTMLElement;

constructor(state: EditorState, { tools, dispatch }) {
constructor(state: EditorState, { tools, dispatch }: EditorConfig) {
this.select = elt(
"select",
{
Expand Down
3 changes: 2 additions & 1 deletion src/components/UndoButton.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import elt from "../utils/createElement";
import { EditorConfig, EditorState, UIComponent } from "../types";

class UndoButton implements UIComponent {
public dom: HTMLButtonElement;
constructor(state, { dispatch }) {
constructor(state: EditorState, { dispatch }: EditorConfig) {
this.dom = <HTMLButtonElement>elt(
"button",
{
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface EditorState {
export interface EditorConfig {
tools: any;
controls: (typeof UIComponent)[];
dispatch: any;
dispatch: (stat: any, action?: any) => void;
}

export interface Position {
Expand Down
File renamed without changes.

0 comments on commit 0618684

Please sign in to comment.