{"record":{"id":"965446a3379a94b4","repo":"remotion-dev/remotion","slug":"type-of-trimbefore-prop-must-be-a-number-instead","errorCode":null,"errorMessage":"type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.","messagePattern":"type of trimBefore prop must be a number, instead got type (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-start-from-props.ts","lineNumber":52,"sourceCode":"\t\tif (endAt <= 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`endAt must be a positive number, instead got ${endAt}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif ((endAt as number) < (startFrom as number)) {\n\t\tthrow new TypeError('endAt prop must be greater than startFrom prop.');\n\t}\n};\n\nexport const validateTrimProps = (\n\ttrimBefore: number | undefined,\n\ttrimAfter: number | undefined,\n) => {\n\tif (typeof trimBefore !== 'undefined') {\n\t\tif (typeof trimBefore !== 'number') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (isNaN(trimBefore) || trimBefore === Infinity) {\n\t\t\tthrow new TypeError('trimBefore prop can not be NaN or Infinity.');\n\t\t}\n\n\t\tif (trimBefore < 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof trimAfter !== 'undefined') {\n\t\tif (typeof trimAfter !== 'number') {\n\t\t\tthrow new TypeError(","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-start-from-props.ts#L34-L70","documentation":"The `trimBefore` prop (the non-deprecated replacement for startFrom) on media components must be a number representing the frame to begin playback from. validateTrimProps checks the runtime type because values from props, config files, or JSON may arrive as strings.","triggerScenarios":"Passing trimBefore as a string (trimBefore=\"60\"), an object, or any non-number non-undefined value to a media component.","commonSituations":"Reading trimBefore from a JSON scene descriptor or CMS where numbers are serialized as strings; passing a value from URL params without conversion; migrating from startFrom but forgetting to convert the type.","solutions":["Pass trimBefore as a numeric literal: trimBefore={60}.","If the value is a string, parse and validate it: trimBefore={Number(myStr)} after a finiteness check.","Omit the prop if you do not need to offset the start."],"exampleFix":"// before\n<Video src={src} trimBefore=\"60\" />\n// after\n<Video src={src} trimBefore={60} />","handlingStrategy":"type-guard","validationCode":"if (trimBefore !== undefined && typeof trimBefore !== 'number') {\n  throw new Error('trimBefore must be a number or undefined');\n}","typeGuard":"const isTrimBefore = (v: unknown): v is number | undefined =>\n  v === undefined || typeof v === 'number';","tryCatchPattern":null,"preventionTips":["Type the prop as number | undefined in wrapper components.","Parse string sources with Number() and validate before passing.","Keep scene/config descriptors typed so numbers are not serialized as strings."],"tags":["validation","props","trimming","typeerror"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}