Good Code
The good version documents exactly which actions and arguments the callback accepts.
Lesson 06
Describe callbacks with the arguments and return value the caller actually supports.
type ReviewAction = "approve" | "request-changes";
type ReviewHandler = (action: ReviewAction, comment: string) => void;
function submitReview(handleReview: ReviewHandler) {
// The callback type limits actions and required arguments.
handleReview("approve", "Ready to merge.");
}function submitReview(handleReview: Function) {
// Function accepts any call shape, so invalid calls compile.
handleReview("approve");
handleReview("delete-branch", 42, true);
}The good version documents exactly which actions and arguments the callback accepts.
The bad version accepts any callable value, so TypeScript cannot help reviewers spot missing arguments, unsupported actions, or unexpected return contracts.