Size / Priority
- Size: Trivial (~30+ sites)
- Category: C.2 Simplifications & DRY.
- Risk: low.
Affected files
- Across the codebase — sites using
settings.x ?? DEFAULT_X to apply per-call defaults.
Background
The pattern is everywhere:
const timeoutMs = options.timeoutMs ?? DEFAULT_ASK_TIMEOUT_MS;
const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
const consistency = options.consistency ?? 'local';
For methods with many optional parameters, this becomes verbose:
async updateAsync(opts) {
const timeoutMs = opts.timeoutMs ?? 5_000;
const consistency = opts.consistency ?? 'local';
const pendingId = opts.pendingId ?? nextPendingId();
// ... etc
}
Could be:
async updateAsync(opts) {
const resolved = applyDefaults(opts, UPDATE_DEFAULTS);
// resolved.timeoutMs, resolved.consistency are guaranteed populated
}
(applyDefaults from #255.)
Target
Same helper as #255 (applyDefaults<S>(partial, defaults)):
- Returns a fully-populated
S from a Partial<S> + a S defaults.
- TypeScript narrows
S correctly.
Cleaner than per-property nullish-coalescing.
Integration / risk
Test plan
- Per-site regression: behaviour unchanged.
- Edge cases: explicit
undefined vs missing field handled consistently.
Acceptance criteria
Size / Priority
Affected files
settings.x ?? DEFAULT_Xto apply per-call defaults.Background
The pattern is everywhere:
For methods with many optional parameters, this becomes verbose:
Could be:
(
applyDefaultsfrom #255.)Target
Same helper as #255 (
applyDefaults<S>(partial, defaults)):Sfrom aPartial<S>+ aSdefaults.Scorrectly.Cleaner than per-property nullish-coalescing.
Integration / risk
Test plan
undefinedvs missing field handled consistently.Acceptance criteria
applyDefaultshelper (shared with [Feature] resolveSettings helper for DRY settings-merge boilerplate #255) used across all sites.Defaultsconstants extracted.