remotion-dev/remotion · error · TypeError
"direction" must be "horizontal" or "vertical", but got ${JS
Error message
"direction" must be "horizontal" or "vertical", but got ${JSON.stringify(params.direction)} What it means
Thrown by validateMirrorParams in the Mirror effect when direction is present but is neither 'horizontal' nor 'vertical'. undefined is accepted (defaults to 'horizontal'). This is a hand-written check (not the shared formatEnum helper) so the message hardcodes the two literals.
Source
Thrown at packages/effects/src/mirror/index.ts:76
invert: boolean;
};
const resolve = (p: MirrorParams): MirrorResolved => ({
direction: p.direction ?? 'horizontal',
position: p.position ?? 0.5,
invert: p.invert ?? false,
});
const validateMirrorParams = (params: MirrorParams): void => {
assertEffectParamsObject(params, 'Mirror');
assertOptionalFiniteNumber(params.position, 'position');
if (
params.direction !== undefined &&
params.direction !== 'horizontal' &&
params.direction !== 'vertical'
) {
throw new TypeError(
`"direction" must be "horizontal" or "vertical", but got ${JSON.stringify(params.direction)}`,
);
}
if (params.invert !== undefined && typeof params.invert !== 'boolean') {
throw new TypeError(
`"invert" must be a boolean, but got ${JSON.stringify(params.invert)}`,
);
}
const {position} = resolve(params);
validateUnitInterval(position, 'position');
};
export const mirror = createEffect<MirrorParams, MirrorState>({
type: 'dev.remotion.effects.mirror',
label: 'mirror()',
documentationLink: 'https://www.remotion.dev/docs/effects/mirror',View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Use 'horizontal' or 'vertical' (the only MirrorDirection values).
- Type the value as MirrorDirection so the compiler rejects bad literals.
- Omit direction to use the default 'horizontal'.
Example fix
// before
mirror({ direction: 'h' })
// after
mirror({ direction: 'horizontal' }) Defensive patterns
Strategy: type-guard
Validate before calling
const MIRROR_DIRECTIONS = ['horizontal', 'vertical'] as const;
type MirrorDirection = (typeof MIRROR_DIRECTIONS)[number];
const isMirrorDirection = (v: unknown): v is MirrorDirection =>
typeof v === 'string' && (MIRROR_DIRECTIONS as readonly string[]).includes(v);
mirror({ direction: isMirrorDirection(d) ? d : 'horizontal' }); Type guard
const isMirrorDirection = (v: unknown): v is 'horizontal' | 'vertical' => v === 'horizontal' || v === 'vertical';
Prevention
- Type direction as MirrorDirection so the compiler rejects invalid literals.
- Mirror has no angle/rotation prop; position/invert are the other knobs.
- Validate values loaded from untyped JSON before passing them in.
When it happens
Trigger: Calling mirror({ direction: 'diagonal' }), mirror({ direction: 'h' }), mirror({ direction: 0 }), or any value that is not exactly 'horizontal' or 'vertical'. Runs after assertEffectParamsObject and assertOptionalFiniteNumber(position), before the position unit-interval check.
Common situations: Typo in the literal; passing a value from untyped/serialized config; confusing direction with a rotation concept (Mirror has no angle prop — use position/invert instead).
Related errors
- "${name}" must be ${formatEnum(variants)}, but got ${JSON.st
- "${name}" must be ${formatEnum(variants)}
- "${name}" must be ${formatEnum(variants)}
- "direction" must be ${formatEnum(LINE_DIRECTIONS)}, but got
- "invert" must be a boolean, but got ${JSON.stringify(params.
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/c8119df51da7d433.
Report an issue: GitHub.