An optional callback parameter is part of the callable contract. A caller may omit it, so the implementation must handle that case.
Worked example
type Task = (name: string, attempt?: number) => string;
const task: Task = (name, attempt = 1) => name + " #" + attempt;
console.log(task("ship"));Result
ship #1Implementation notes
Optionality in a callback signature specifies what the caller may omit. Marking every parameter optional can unnecessarily burden callback implementations.
Try it yourself
Invoke the same function with an argument, without it and with a falsy value.
Open the TypeScript example →Editorial date May 4, 2026 · Published December 6, 2026