no more ReturnType<typeof>

This commit is contained in:
2025-10-19 15:55:52 +01:00
parent a6f066d738
commit 252027dab2
13 changed files with 1242 additions and 90 deletions
+12 -14
View File
@@ -118,18 +118,16 @@ export function useScore({ board, hero, gameStatusManager, keyManager }: UseScor
setFinalScore(score);
}, [gameStatus, logicFirst, logicLast, timeValue, optimalSteps]);
return {
timeValue,
startTimer,
stopTimer,
resetTimer,
distToKey,
distToExit,
keystrokes,
optimalSteps,
efficiency,
finalScore,
};
return {
timeValue,
startTimer,
stopTimer,
resetTimer,
distToKey,
distToExit,
keystrokes,
optimalSteps,
efficiency,
finalScore,
};
}
export type ScoreManager = ReturnType<typeof useScore>;
+6 -6
View File
@@ -1,12 +1,14 @@
import { useEffect, useState } from "react";
import type { BoardManager } from "../types";
import type { BoardManager, Coord, ScorePathsResult } from "../types";
export type { ScorePathsResult } from "../types";
type UseScorePathsParams = {
board: BoardManager;
heroPos: { row: number; col: number } | null;
heroPos: Coord | null;
};
export function useScorePaths({ board, heroPos }: UseScorePathsParams) {
export function useScorePaths({ board, heroPos }: UseScorePathsParams): ScorePathsResult {
const { mazeInstanceRef } = board;
const [distances, setDistances] = useState({
@@ -38,7 +40,5 @@ export function useScorePaths({ board, heroPos }: UseScorePathsParams) {
}));
}, [heroPos, mazeInstanceRef]);
return distances;
return distances;
}
export type UseScorePathsReturn = ReturnType<typeof useScorePaths>;
+2 -3
View File
@@ -1,10 +1,9 @@
import { useEffect, useRef } from "react";
import type { UseTimerReturn } from "./useTimer";
import type { GameStatus } from "../types";
import type { TimerManager, GameStatus } from "../types";
type UseScoreTimeParams = {
gameStatus: GameStatus;
timer: UseTimerReturn;
timer: TimerManager;
};
export function useScoreTime({ gameStatus, timer }: UseScoreTimeParams) {
+5 -4
View File
@@ -1,6 +1,9 @@
import { useState, useRef, useEffect } from "react";
import type { TimerManager } from '../types';
export function useTimer() {
export type { TimerManager } from '../types';
export function useTimer(): TimerManager {
const [timeValue, setTimeValue] = useState(0);
const startTimeRef = useRef<number | null>(null);
const frameRef = useRef<number | null>(null);
@@ -42,7 +45,5 @@ export function useTimer() {
};
}, []);
return { timeValue, startTimer, stopTimer, resetTimer };
return { timeValue, startTimer, stopTimer, resetTimer };
}
export type UseTimerReturn = ReturnType<typeof useTimer>;