remotion-dev/remotion · error · TypeError
Cannot interpolate an input which is not a number
Error message
Cannot interpolate an input which is not a number
What it means
Thrown by interpolate() after the undefined check and range validation, when typeof input !== 'number'. Because undefined is already caught earlier, this fires for other non-number inputs: strings, booleans, objects, null, bigint, symbols, and functions. NaN does not hit this (typeof NaN === 'number') but is handled by extrapolation/clamping downstream.
Source
Thrown at packages/core/src/interpolate.ts:1169
if (inputRange.length !== outputRange.length) {
throw new Error(
'inputRange (' +
inputRange.length +
') and outputRange (' +
outputRange.length +
') must have the same length',
);
}
checkInfiniteRange('inputRange', inputRange);
checkValidInputRange(inputRange);
assertValidInterpolateEasingOption(options?.easing, inputRange.length);
assertValidInterpolatePosterizeOption(options?.posterize);
assertValidInterpolateOutputOption(options?.output);
if (typeof input !== 'number') {
throw new TypeError('Cannot interpolate an input which is not a number');
}
if (!Array.isArray(outputRange)) {
throw new Error('outputRange must contain only numbers');
}
const hasStringOutput = outputRange.some(
(output) => typeof output === 'string',
);
if (hasStringOutput) {
if (
!outputRange.every(
(output) => typeof output === 'string' || typeof output === 'number',
)
) {
throw new TypeError(
'outputRange must contain only numbers, or supported scale, translate, and rotate strings',
);View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Coerce the input with Number() and confirm the result is a finite number.
- Type the variable as number upstream so the bad value is caught at compile time.
- Guard the call site to skip interpolation for non-number inputs.
Example fix
// before const r = interpolate(frameStr, [0, 1], [0, 100]); // frameStr is a string // after const r = interpolate(Number(frameStr), [0, 1], [0, 100]);
Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof input !== 'number') {
throw new Error('input must be a number');
}
const r = interpolate(input, inputRange, outputRange); Type guard
const isNumber = (v: unknown): v is number => typeof v === 'number';
Prevention
- Coerce string sources with Number() and check for NaN.
- Type the input as number in component props and function signatures.
- Guard the call site to skip interpolation for non-number inputs.
When it happens
Trigger: interpolate('0', [0,1], [0,100]); interpolate(null, [...], [...]); interpolate(true, [...], [...]); passing a frame value read from a string source without coercion.
Common situations: Reading the current value from a DOM input or URL param (string) and passing it uncoerced; passing an object that wraps a number; null from an optional chain.
Related errors
- outputRange tuples must contain only finite numbers, but got
- ${name} must contain only numbers
- input can not be undefined
- outputRange must contain only numbers
- outputRange must contain only numbers, numeric tuples, or su
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/9da1ecd64c39cf82.
Report an issue: GitHub.