From 18df1329b43b596d111c83783c4b1b6f6312a54f Mon Sep 17 00:00:00 2001 From: shueja-personal Date: Mon, 2 Sep 2024 23:50:30 -0700 Subject: [PATCH] Fix TSC failing on main --- src/document/path/ChoreoTrajStore.ts | 1 + src/util/MathUtil.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/document/path/ChoreoTrajStore.ts b/src/document/path/ChoreoTrajStore.ts index ced32218c..885370c5f 100644 --- a/src/document/path/ChoreoTrajStore.ts +++ b/src/document/path/ChoreoTrajStore.ts @@ -16,6 +16,7 @@ export const ChoreoTrajStore = types }) .views((self) => ({ get fullTraj(): SwerveSample[] | DifferentialDriveSample[] { + //@ts-expect-error This might be a TS bug, flatMap on an A[] | B[] returns an (A | B)[] return self.samples.flatMap((sect, i, samp) => { if (i != 0) { return sect.slice(1); diff --git a/src/util/MathUtil.ts b/src/util/MathUtil.ts index 48b886fd2..479b7db91 100644 --- a/src/util/MathUtil.ts +++ b/src/util/MathUtil.ts @@ -1,4 +1,7 @@ -import { SwerveSample } from "../document/2025/DocumentTypes"; +import { + DifferentialDriveSample, + SwerveSample +} from "../document/2025/DocumentTypes"; /** * A port of WPILib's MathUtil.inputModulus @@ -29,7 +32,7 @@ export function angleModulus(input: number) { } export type Pose = { x: number; y: number; rot: number }; -export function storeToPose(store: SwerveSample) { +export function storeToPose(store: SwerveSample | DifferentialDriveSample) { return { x: store.x, y: store.y, rot: store.heading }; } export function interpolate(p1: Pose, p2: Pose, frac: number) { @@ -46,7 +49,7 @@ export function interpolate(p1: Pose, p2: Pose, frac: number) { } export function sample( timeSeconds: number, - m_states: Array + m_states: Array | Array ): Pose { if (timeSeconds <= m_states[0].t) { return storeToPose(m_states[0]);