回调中的可选参数

❌ 不要在回调中使用可选参数,除非你真的是这个意思:

Don't use optional parameters in callbacks unless you really mean it:

/* WRONG */
interface Fetcher {
  getObject(done: (data: unknown, elapsedTime?: number) => void): void;
}

SWvatsF7gNnYjHPmC5lKK1CUQB+orXl5phOSx1LkletH2oJXv7ORRG3HMUUHLxE22dr9phrldSkaDcll3l8VXp7WGnqNkpgmIKjo4FP+iRhVrAaznPav05ZT3lV0uztBUl6QYh6BU5fWZ0BF6jvvJCcL4hqK/fyCjeThe7xLnFZ0A449daLB7/4gXLT04YVGZW0iwNn80AhjCWELMHhkMQE9R24P1cYZJIDuR/sXh4OF5zvlqvpmCpmNNNd1NH6V+H0xFjXJ6OmCDaIyzAlAb78zHScLZGPM9yjEZbKp+X5adSxkkT5jPT7UC3hGPiD5aodOEV6SMMeYV9PL0alv+QLwOv1lew7J15Whl2L/b6VnZIofIr0a4nK8pLRKqqhJpOa4dGXUAJVuJStlMvuA9rScEInWgO8atvB1+wD9oRFSblsrW2deJ+e0F5b3C9+GZf5Ky3SHJdT5HzICAAitjM17d1cc3PYYRnLpoKZZYSU4cU/KJw/a8bTERMK8GCZh1T0KLdhcUO3DajIE8QfQS5eIcbYwNpw2nkskpyhnEQrKE9+cXLCLD8V7Qy9KU8JpjhljXGJBlkTkcOdpHBsgStdTeE7tZP3HlWYr3WhshrqrO6c53392Bilo9GjrNTW+bidspjmaFtgRkYM/TftVKTQ/aTIzxGmpVnHF7RhlJSHXZWpaBgCOy2UMtwLsQPgy+7myyhldQ7ECntPDbJBxfk5MiGrvaLNk3ASzNz4dtpmZAqCqaqxOYLIqkXM+aj/Nny2PmqaABn6m0Sr89P4+DJyFt36oE1Ay7PvRWJDTM/Gl1xj45W+6OabBCmcGchE34egEbk55Q4M5wM1/rsdOBE4VSyyKTaTFG5GTEiojX3F9QpLw2LRI9WJklg4EgY2xcGNQZbyk8csiinRSa37MOB4OfJY99Go90FiFmpv5nP7AK1eVscXbXk0wtdcOxxad7T6/Zv1byIT0dQou3XP71g==

/NxkysiCi5qyvV+P1m5mmYoOGXmXsX4ZpSPWv34TsL1EXrBwOOaDdxkucrmmMeRUqHaLaDmj1T/xFF9lzGiDfXAryF4gvhoHMKeUy2TMyrnhQghmNC4ZZ/GYjR88g3U7O1PVvVEqyjQKiwRakpqZk20oThal31X6dIPN1Ne2y/R5URS1jVPtJZkKXu2mbHkQ

/* OK */
interface Fetcher {
  getObject(done: (data: unknown, elapsedTime: number) => void): void;
}