withastro/astro · warning

Expected second parameter to be an array, received a ${typeo

Error message

Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])

What it means

Astro.slots.render(name, args) spreads the second parameter's items as function arguments into a slot defined as an inline expression. The contract is a single array; passing anything else (string, number, object) makes the render misbehave, so render() warns about the received type and shows how to pass an array as one argument ([[...]]) when that is the intent.

Source

Thrown at packages/astro/src/core/render/slots.ts:61

						return true;
					},
					enumerable: true,
				});
			}
		}
	}

	public has(name: string) {
		if (!this.#slots) return false;
		return Boolean(this.#slots[name]);
	}

	public async render(name: string, args: any[] = []) {
		if (!this.#slots || !this.has(name)) return;

		const result = this.#result;
		if (!Array.isArray(args)) {
			this.#logger.warn(
				null,
				`Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])`,
			);
		} else if (args.length > 0) {
			const slotValue = this.#slots[name];
			const component = typeof slotValue === 'function' ? await slotValue(result) : await slotValue;

			// Astro
			const expression = getFunctionExpression(component);
			if (expression) {
				const slot = async () =>
					typeof expression === 'function' ? expression(...args) : expression;
				return await renderSlotToString(result, slot).then((res) => {
					return res;
				});
			}
			// JSX
			if (typeof component === 'function') {

View on GitHub (pinned to 52e6c34790)

Solutions

  1. Wrap the arguments in an array: Astro.slots.render('default', ['Hello'])
  2. If the slot must receive a single array argument, nest it: Astro.slots.render('default', [['Hello', 'World']])
  3. Type the call site (args: any[]) so the wrong shape is caught by tooling before runtime

Example fix

// before
const html = await Astro.slots.render('default', 'Hello');

// after — one string argument
const html = await Astro.slots.render('default', ['Hello']);
// or: single array argument
const html = await Astro.slots.render('default', [['Hello', 'World']]);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!Array.isArray(args)) args = [args]; // normalize before render
const html = await Astro.slots.render('default', args);

Type guard

function isArgsArray(args: unknown): args is any[] {
  return Array.isArray(args);
}

Prevention

When it happens

Trigger: Calling Astro.slots.render('default', 'Hello'), Astro.slots.render('default', 42), or any non-array second argument; or wanting a slot parameter that is itself an array and passing it un-nested.

Common situations: Porting component APIs where a scalar was passed; refactoring a callback-slot component so it receives one array parameter; copy-pasting slot render calls between components with different signatures.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18). Data as JSON: /api/errors/33c0deb52e01da6e. Report an issue: GitHub.