"fix" some typescript errors

This commit is contained in:
Joeri Exelmans 2025-10-14 13:42:45 +02:00
parent b14b9e205c
commit a73d51a31a
2 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from "react"; import { Dispatch, SetStateAction } from "react";
import { Statechart, stateDescription } from "../statecharts/abstract_syntax"; 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 { formatTime } from "./util";
import { TimeMode } from "../statecharts/time"; import { TimeMode } from "../statecharts/time";
@ -24,7 +24,7 @@ export function RTHistory({rt, rtIdx, ast, setRTIdx, setTime}: RTHistoryProps) {
<ShowMode mode={rt.mode} statechart={ast}/> <ShowMode mode={rt.mode} statechart={ast}/>
<ShowEnvironment environment={rt.environment}/> <ShowEnvironment environment={rt.environment}/>
{rt.outputEvents.length>0 && <div> {rt.outputEvents.length>0 && <div>
{rt.outputEvents.map((e:string) => '^'+e).join(', ')} {rt.outputEvents.map((e:RaisedEvent) => '^'+e.name).join(', ')}
</div>} </div>}
</div></>); </div></>);
} }

View file

@ -1,5 +1,5 @@
import * as lz4 from "@nick/lz4"; 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 { Statechart } from "../statecharts/abstract_syntax";
import { Arrow, ArrowPart, Rountangle, RountanglePart, VisualEditorState, emptyState, findNearestArrow, findNearestRountangleSide, findRountangle } from "../statecharts/concrete_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); return () => clearTimeout(timeout);
}, [state]); }, [state]);
function getCurrentPointer(e: MouseEvent) { function getCurrentPointer(e: {pageX: number, pageY: number}) {
const bbox = refSVG.current!.getBoundingClientRect(); const bbox = refSVG.current!.getBoundingClientRect();
return { return {
x: e.pageX - bbox.left, x: e.pageX - bbox.left,
@ -157,7 +157,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps)
} }
} }
const onMouseDown: MouseEventHandler<SVGSVGElement> = (e) => { const onMouseDown = (e: MouseEvent) => {
const currentPointer = getCurrentPointer(e); const currentPointer = getCurrentPointer(e);
if (e.button === 1) { if (e.button === 1) {
@ -247,7 +247,7 @@ export function VisualEditor({setAST, rt, errors, setErrors}: VisualEditorProps)
setSelection([]); setSelection([]);
}; };
const onMouseMove = (e: MouseEvent) => { const onMouseMove = (e: {pageX: number, pageY: number}) => {
const currentPointer = getCurrentPointer(e); const currentPointer = getCurrentPointer(e);
if (dragging) { if (dragging) {
const pointerDelta = subtractV2D(currentPointer, dragging.lastMousePos); 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) { if (dragging) {
setDragging(null); setDragging(null);
// do not persist sizes smaller than 40x40 // do not persist sizes smaller than 40x40