Skip to content
Chapter 102Lesson 4

Quiz - Docs that live in the code

Quiz progress

0 / 0

You’re deciding which of these declarations earns a TSDoc block. Which one earns it?

A private helper used once, in the same file it’s defined in.
A Server Action a component calls from another module.
type UserInput = z.infer<typeof userInputSchema>.

A teammate writes this @param on a function with the signature createCustomer(email: string):

/**
* Creates a Stripe customer.
*
* @param {string} email - the user's email
*/

What’s wrong with it?

The {string} type duplicates what the TypeScript signature already states — TSDoc tags never carry types.
The summary should restate the parameter and return types so the hover is complete.
@param should always be omitted; the parameter name is enough.

Same line of code, two files. Which comment earns its place?

// add one to the retry count
retries += 1;
// Stripe retries this webhook up to 3×; cap our own retry so the two don't compound into 9 attempts.
retries += 1;

Which of these // why comments should be promoted out of prose into something the compiler or runtime enforces? Select all that apply.

// callers must run safeParse on the body before this touches the DB
// don't reorder: the audit insert has to land before we enqueue the email
// timestamps come back rounded to the microsecond, so compare rounded values
// the same webhook can land twice and in either order

A PR splits the test suite and renames pnpm test to pnpm test:unit. The README still says pnpm test. Your teammate suggests fixing the README in a quick follow-up PR right after this one merges. Why isn’t that good enough?

Between the two merges, main is self-contradictory — a live wrong doc in production for the whole window, and a wrong doc is worse than no doc.
A follow-up PR is fine; the README isn’t code, so its accuracy isn’t urgent.
The README should never mention commands at all, so neither PR is needed.

A reviewer wants to know which doc-drift checks they can hand off to automation and which they have to run themselves. Which of these is the one a machine can fully catch — no human judgment needed?

Whether .env.example declares the same set of keys as env.ts.
Whether a TSDoc summary sentence still describes what the function actually does.
Whether this PR’s new behavior warranted an ADR nobody wrote.

Quiz complete

Score by topic