Simplify tick.ts typing

This commit is contained in:
Tangent Wantwight 2024-01-27 23:57:09 -05:00
parent 063dd636bb
commit b05cdab771

View file

@ -1,13 +1,9 @@
import { Cancel, Source } from "./source";
import { Source } from "./source";
export type PhysicsTick = ["physics"];
export type RenderTick = ["render", number];
export function tick(fps: number): Source<PhysicsTick | RenderTick> {
function tickSource(): PhysicsTick;
function tickSource(
callback: (tick: PhysicsTick | RenderTick) => void
): Cancel;
function tickSource(callback?: (tick: PhysicsTick | RenderTick) => void) {
if (callback) {
let lastPhysicsTick: number = new Date().getTime();
@ -32,5 +28,5 @@ export function tick(fps: number): Source<PhysicsTick | RenderTick> {
}
}
return tickSource;
return tickSource as Source<PhysicsTick | RenderTick>;
}