{"record":{"id":"640a1f6cb6bc747d","repo":"remotion-dev/remotion","slug":"translate-supports-only-the-following-signatures","errorCode":null,"errorMessage":"translate() supports only the following signatures:\ntranslate(x: LengthPercentageUnitString)\ntranslate(x: number)\ntranslate(x: number, y: number)\ntranslate(translation: number, unit: LengthPercentageUnit)\ntranslate(x: number, unitX: LengthPercentageUnit, y: number, unitY: LengthPercentageUnit): string;","messagePattern":"translate\\(\\) supports only the following signatures:\ntranslate\\(x: LengthPercentageUnitString\\)\ntranslate\\(x: number\\)\ntranslate\\(x: number, y: number\\)\ntranslate\\(translation: number, unit: LengthPercentageUnit\\)\ntranslate\\(x: number, unitX: LengthPercentageUnit, y: number, unitY: LengthPercentageUnit\\): string;","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts","lineNumber":406,"sourceCode":"\t\t}\n\n\t\t// Case D\n\t\tif (typeof arg1 === 'number' && typeof arg2 !== 'number') {\n\t\t\tcheckNumber({num: arg1, param: 'x', api: 'translate'});\n\t\t\treturn `translate(${arg1}${arg2})`;\n\t\t}\n\t}\n\n\tif (arguments.length === 4) {\n\t\t// Case E\n\t\tif (typeof arg1 === 'number' && typeof arg3 === 'number') {\n\t\t\tcheckNumber({num: arg1, param: 'x', api: 'translate'});\n\t\t\tcheckNumber({num: arg3, param: 'y', api: 'translate'});\n\t\t\treturn `translate(${arg1}${arg2}, ${arg3}${arg4})`;\n\t\t}\n\t}\n\n\tthrow new TypeError(\n\t\t[\n\t\t\t`translate() supports only the following signatures:`,\n\t\t\t`translate(x: LengthPercentageUnitString)`,\n\t\t\t`translate(x: number)`,\n\t\t\t`translate(x: number, y: number)`,\n\t\t\t`translate(translation: number, unit: LengthPercentageUnit)`,\n\t\t\t`translate(x: number, unitX: LengthPercentageUnit, y: number, unitY: LengthPercentageUnit): string;`,\n\t\t].join('\\n'),\n\t);\n}\n\nfunction translate3d(\n\tx: LengthPercentageUnitString | number,\n\ty: LengthPercentageUnitString | number,\n\tz: LengthPercentageUnitString | number,\n): string;\nfunction translate3d(\n\tx: number,","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts#L388-L424","documentation":"`translate()` accepts only 1, 2, or 4 arguments in specific type combinations (length/percentage unit string, number, or number+unit pairs). Any other arity (0, 3, 5+) or a type combo that fits no case (e.g. a number paired with a non-unit string, or a string that is not a length/percentage unit) falls through to this exhaustive signature list. The message lists every accepted signature.","triggerScenarios":"Calling `translate()` with no args; `translate(1, 2, 3)` (3 args); `translate('50gr')` (not a length/percentage unit); `translate(10, 'deg')` (deg is not a length/percentage unit); `translate(10, 'px', 20)` (wrong arity for the 4-arg form).","commonSituations":"Passing angle units (`deg`) into translate; passing a plain string that does not include a recognized unit suffix; variable-length argument arrays with the wrong count; confusing the 2-arg number form `translate(x, y)` with the number+unit form `translate(x, unit)`.","solutions":["Match your call to a listed signature: `translate('50px')`, `translate(50)`, `translate(50, 20)`, `translate(50, 'px')`, or `translate(50, 'px', 20, 'px')`.","Use only length (`px`, `em`, etc.) or percentage (`%`) units, not angle units.","Check `arguments.length` is 1, 2, or 4 when building calls dynamically.","Drop `as any` so the overload list guides the call at compile time."],"exampleFix":"// before\nconst t = translate(50, 'deg'); // deg is not a length unit\n\n// after\nconst t = translate(50, 'px');","handlingStrategy":"validation","validationCode":"// Validate translate() arguments match a supported signature before calling.\nconst LENGTH_UNITS = ['px', 'em', 'rem', 'vw', 'vh', '%'] as const;\ntype LengthUnit = (typeof LENGTH_UNITS)[number];\n\nconst isLengthUnitString = (v: unknown): v is string => {\n  if (typeof v !== 'string') return false;\n  return LENGTH_UNITS.some((u) => {\n    if (!v.endsWith(u)) return false;\n    return Number.isFinite(Number(v.slice(0, v.length - u.length)));\n  });\n};\n// Prefer calling a fixed overload: translate('50px'), translate(50), translate(50,20).","typeGuard":"const isLengthUnit = (v: unknown): v is LengthUnit =>\n    typeof v === 'string' && (LENGTH_UNITS as readonly string[]).includes(v);\n\nconst isLengthUnitString = (v: unknown): v is string => {\n  if (typeof v !== 'string') return false;\n  return LENGTH_UNITS.some((u) =>\n    v.endsWith(u) && Number.isFinite(Number(v.slice(0, v.length - u.length))),\n  );\n};","tryCatchPattern":null,"preventionTips":["Use a single fixed overload (e.g. `translate('50px')` or `translate(50, 20)`) rather than dynamic arity.","Never pass angle units (deg) to translate; only length/percentage units are valid.","Keep translate() arity at 1, 2, or 4 when building calls dynamically.","Remove `as any` so the overloads guide the call."],"tags":["transform","translate","validation","runtime","overload"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}