找出 firstLabel 里的 bug

来自 基础类型
TypeScript 6 入门 4分钟 找出 1处问题

找出这个生成的标签辅助函数中未经检查的假设。

TypeScript
function firstLabel(labels: string[]): string {
  return labels[0].toUpperCase();
}

console.log(firstLabel([]));
在试验场中打开
报告错误