```ts
/**
 * Wraps the given text into lines such that no line exceeds the specified width.
 * @param text - The input string to wrap.
 * @param width - The maximum width of each line.
 * @returns An array of wrapped lines.
 */
export function wrapText(text: string, width: number): string[] {
  if (typeof text !== 'string') {
    throw new Error('Text must be a string');
  }
  if (!Number.isInteger(width) || width <= 0) {
    throw new Error('Width must be a positive integer');
  }
  if (text.startsWith(' ') || text.endsWith(' ') || /\s{2,}/.test(text)) {
    throw new Error('Text must not have leading, trailing, or doubled spaces');
  }

  const words = text.split(' ');
  const lines: string[] = [];
  let currentLine = '';

  for (const word of words) {
    if (word.length > width) {
      // If a single word is longer than the width, it gets its own line
      lines.push(word);
      continue;
    }

    if ((currentLine + word).length <= width) {
      if (currentLine !== '') {
        currentLine += ' ';
      }
      currentLine += word;
    } else {
      lines.push(currentLine);
      currentLine = word;
    }
  }

  if (currentLine !== '') {
    lines.push(currentLine);
  }

  return lines;
}
```