TS 定义函数的可选参数类型

index.ts

function foo(name: string, age?: number) {
  console.log(name + age);
}

foo("a"); // "aundefined"
原文地址:https://www.cnblogs.com/aisowe/p/15246025.html