Skip to content

prefer-named-callback-domain

Name literal-union domains used by callbacks in exported contracts.

Why

An inline callback domain hides a reusable vocabulary at the point where callers and implementations must agree.

Fix

Extract the literal union to a named type and use that type in the callback parameter.

Examples

Before — flagged Do not inline a public callback domain
src/options.ts
export interface Options {
done?: (boundary: "seeded" | "queued") => void;
}
After — preferred Name the callback domain
src/options.ts
export type Boundary = "seeded" | "queued";
export interface Options {
done?: (boundary: Boundary) => void;
}