{"record":{"id":"8ce774ab2e20757f","repo":"remotion-dev/remotion","slug":"inputrange-can-not-be-undefined","errorCode":null,"errorMessage":"inputRange can not be undefined","messagePattern":"inputRange can not be undefined","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx","lineNumber":286,"sourceCode":"\t}\n}\n\n/*\n * @description A function that interpolates between two styles based on an input range.\n * @see [Documentation](https://remotion.dev/docs/animation-utils/interpolate-styles)\n */\nexport const interpolateStyles = (\n\tinput: number,\n\tinputRange: number[],\n\toutputStylesRange: Style[],\n\toptions?: InterpolateOptions,\n) => {\n\tif (typeof input === 'undefined') {\n\t\tthrow new Error('input can not be undefined');\n\t}\n\n\tif (typeof inputRange === 'undefined') {\n\t\tthrow new Error('inputRange can not be undefined');\n\t}\n\n\tif (typeof outputStylesRange === 'undefined') {\n\t\tthrow new Error('outputRange can not be undefined');\n\t}\n\n\tif (inputRange.length !== outputStylesRange.length) {\n\t\tthrow new Error(\n\t\t\t'inputRange (' +\n\t\t\t\tinputRange.length +\n\t\t\t\t') and outputStylesRange (' +\n\t\t\t\toutputStylesRange.length +\n\t\t\t\t') must have the same length',\n\t\t);\n\t}\n\n\tcheckInputRange(inputRange);\n\tcheckStylesRange(outputStylesRange);","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx#L268-L304","documentation":"Thrown at the top of interpolateStyles when the inputRange argument is undefined. Same runtime-guard pattern as the input check; it catches calls that omit the range or pass an optional array that was never loaded.","triggerScenarios":"Calling interpolateStyles(frame, undefined, styles); passing a range from config that was not yet loaded.","commonSituations":"Optional config that may be undefined; a delayed data load where interpolateStyles runs before the range is available.","solutions":["Default to a valid range array: interpolateStyles(frame, maybeRange ?? [0, 30], styles).","Validate config presence before calling (e.g. guard with if (!range) return fallbackStyle).","Type the variable as number[] so the compiler flags undefined at the call site."],"exampleFix":"// before\ninterpolateStyles(frame, maybeRange, [{opacity: 1}, {opacity: 0}]);\n\n// after\ninterpolateStyles(frame, maybeRange ?? [0, 30], [{opacity: 1}, {opacity: 0}]);","handlingStrategy":"validation","validationCode":"if (!Array.isArray(inputRange)) {\n  throw new Error('inputRange must be provided');\n}","typeGuard":"const isNumberArray = (v: unknown): v is number[] => Array.isArray(v) && v.every((x) => typeof x === 'number');","tryCatchPattern":null,"preventionTips":["Type inputRange as number[] so the compiler rejects undefined.","Guard with if (!inputRange) return fallbackStyle for optional config.","Default optional ranges with ?? [0, duration]."],"tags":["interpolate-styles","input-range","validation","undefined"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}