From a73d51a31a849cad4e2cd942ae52e06abb2beee1 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Tue, 14 Oct 2025 13:42:45 +0200 Subject: [PATCH] "fix" some typescript errors --- src/App/RTHistory.tsx | 4 ++-- src/VisualEditor/VisualEditor.tsx | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/App/RTHistory.tsx b/src/App/RTHistory.tsx index 3b65402..8011f17 100644 --- a/src/App/RTHistory.tsx +++ b/src/App/RTHistory.tsx @@ -1,6 +1,6 @@ import { Dispatch, SetStateAction } from "react"; import { Statechart, stateDescription } from "../statecharts/abstract_syntax"; -import { BigStep, Environment, Mode } from "../statecharts/runtime_types"; +import { BigStep, Environment, Mode, RaisedEvent } from "../statecharts/runtime_types"; import { formatTime } from "./util"; import { TimeMode } from "../statecharts/time"; @@ -24,7 +24,7 @@ export function RTHistory({rt, rtIdx, ast, setRTIdx, setTime}: RTHistoryProps) { {rt.outputEvents.length>0 &&
- {rt.outputEvents.map((e:string) => '^'+e).join(', ')} + {rt.outputEvents.map((e:RaisedEvent) => '^'+e.name).join(', ')}
} ); } diff --git a/src/VisualEditor/VisualEditor.tsx b/src/VisualEditor/VisualEditor.tsx index a38e153..7b2e82c 100644 --- a/src/VisualEditor/VisualEditor.tsx +++ b/src/VisualEditor/VisualEditor.tsx @@ -1,5 +1,5 @@ import * as lz4 from "@nick/lz4"; -import { Dispatch, MouseEventHandler, SetStateAction, useEffect, useRef, useState } from "react"; +import { Dispatch, MouseEventHandler, SetStateAction, useEffect, useRef, useState, MouseEvent } from "react"; import { Statechart } from "../statecharts/abstract_syntax"; import { Arrow, ArrowPart, Rountangle, RountanglePart, VisualEditorState, emptyState, findNearestArrow, findNearestRountangleSide, findRountangle } from "../statecharts/concrete_syntax"; @@ -149,7 +149,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps) return () => clearTimeout(timeout); }, [state]); - function getCurrentPointer(e: MouseEvent) { + function getCurrentPointer(e: {pageX: number, pageY: number}) { const bbox = refSVG.current!.getBoundingClientRect(); return { x: e.pageX - bbox.left, @@ -157,7 +157,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps) } } - const onMouseDown: MouseEventHandler = (e) => { + const onMouseDown = (e: MouseEvent) => { const currentPointer = getCurrentPointer(e); if (e.button === 1) { @@ -247,7 +247,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps) setSelection([]); }; - const onMouseMove = (e: MouseEvent) => { + const onMouseMove = (e: {pageX: number, pageY: number}) => { const currentPointer = getCurrentPointer(e); if (dragging) { const pointerDelta = subtractV2D(currentPointer, dragging.lastMousePos); @@ -300,7 +300,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps) } }; - const onMouseUp = (e: MouseEvent) => { + const onMouseUp = () => { if (dragging) { setDragging(null); // do not persist sizes smaller than 40x40