no more ReturnType<typeof>
This commit is contained in:
+12
-14
@@ -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>;
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user