Skip to content

🎥 Make videos programmatically with React

Update measure-spring.ts

Jonny Burgerc2275d0c1a2d
diff --git a/packages/core/src/spring/measure-spring.ts b/packages/core/src/spring/measure-spring.ts
index 54351c8389..44b94297f6 100644
--- a/packages/core/src/spring/measure-spring.ts
+++ b/packages/core/src/spring/measure-spring.ts
@@ -1,9 +1,21 @@
+import type {ENABLE_V5_BREAKING_CHANGES} from '../v5-flag.js';
import {validateFps} from '../validation/validate-fps.js';
import type {SpringConfig} from './spring-utils';
import {springCalculation} from './spring-utils.js';
const cache = new Map<string, number>();
+type V4Props = {
+ from?: number;
+ to?: number;
+};
+
+type MeasureSpringProps = {
+ fps: number;
+ config?: Partial<SpringConfig>;
+ threshold?: number;
+} & (false extends typeof ENABLE_V5_BREAKING_CHANGES ? V4Props : {});
+
/**
* @description The function returns how long it takes for a spring animation to settle
* @see [Documentation](https://www.remotion.dev/docs/measure-spring)
@@ -12,13 +24,7 @@ export function measureSpring({
fps,
config = {},
threshold = 0.005,
-}: {
- fps: number;
- config?: Partial<SpringConfig>;
- threshold?: number;
- from?: number;
- to?: number;
-}): number {
+}: MeasureSpringProps): number {
if (typeof threshold !== 'number') {
throw new TypeError(
`threshold must be a number, got ${threshold} of type ${typeof threshold}`,