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

  1. Use 'horizontal' or 'vertical' (the only MirrorDirection values).
  2. Type the value as MirrorDirection so the compiler rejects bad literals.
  3. 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

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


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/c8119df51da7d433. Report an issue: GitHub.