```ts
export function flatten(items: readonly unknown[], depth?: number): unknown[] {
    if (depth !== undefined && (typeof depth !== 'number' || !Number.isInteger(depth) || depth < 0)) {
        throw new Error('Depth must be a non-negative integer or Infinity');
    }

    const result: unknown[] = [];
    const flattenHelper = (arr: readonly unknown[], currentDepth: number): void => {
        for (const item of arr) {
            if (Array.isArray(item) && (depth === undefined || currentDepth < depth)) {
                flattenHelper(item, currentDepth + 1);
            } else if (typeof item !== 'string') {
                result.push(item);
            }
        }
    };

    flattenHelper(items, 0);
    return result;
}
```