function createAggregateError(errors, message, options = {}) {
	// @ts-expect-error for tests
	if (typeof AggregateError === "undefined") {
		const error = new Error(message);

		if (options.cause) {
			/** @type {AggregateError} */
			(error).cause = options.cause;
		}

		/** @type {AggregateError} */
		(error).errors = errors;

		return /** @type {AggregateError} */ (error);
	}

	// @ts-expect-error for tests
	return new AggregateError(errors, message, options);
}
@param {EXPECTED_ANY[]} errors errors
@param {string} message message
@param {{ cause?: unknown }=} options options
@returns {AggregateError} error with errors and cause