add dev guard

This commit is contained in:
arc-alex
2025-03-23 18:39:03 +08:00
parent 7c642f3832
commit c33cbbea7d
+9 -2
View File
@@ -161,9 +161,16 @@ export function getRuntimeOffset(state: RuntimeState): number {
* should always be calculated after the absolute offset
*/
export function getRelativeOffset(state: RuntimeState): number {
const { actualStart, plannedStart } = state.runtime;
const { actualStart, plannedStart, offset } = state.runtime;
// eslint-disable-next-line no-unused-labels -- dev code path
DEV: {
// we know actualStart and plannedStart exists as long as a timer is running
if (actualStart === null || plannedStart === null) {
throw new Error('timerUtils.calculate: actualStart and plannedStart must be set');
}
}
const relativeStartOffset = actualStart - plannedStart;
return state.runtime.offset + relativeStartOffset;
return offset + relativeStartOffset;
}
/**