Skip to content

chore(theme): drop NULL_COLOR symbol indirection in vscode-color-registry#170

Open
dormouse-bot wants to merge 1 commit into
mainfrom
chore/registry-default-simplify
Open

chore(theme): drop NULL_COLOR symbol indirection in vscode-color-registry#170
dormouse-bot wants to merge 1 commit into
mainfrom
chore/registry-default-simplify

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

vscode-color-registry.ts had a three-piece symbol layer — NULL_COLOR (a Symbol), the ResolvedColor type (string | typeof NULL_COLOR), and registryDefault() returning ResolvedColor — whose only purpose was to let registryDefaultValue() immediately collapse the symbol back to string | null:

export function registryDefault(name, themeKind): ResolvedColor {
  const defaults = REGISTRY_DEFAULTS[name];
  if (!defaults) return NULL_COLOR;
  const value = defaults[themeKind];
  if (value) return value;
  return NULL_COLOR;
}
export function registryDefaultValue(name, themeKind): string | null {
  const value = registryDefault(name, themeKind);
  return value === NULL_COLOR ? null : value;
}

The symbol never escaped the module — nothing outside imports NULL_COLOR, ResolvedColor, or registryDefault (the resolver imports only registryDefaultValue). The indirection added a layer with no caller benefit, so this folds the lookup directly into registryDefaultValue and drops the dead symbol/type/function:

export function registryDefaultValue(name, themeKind): string | null {
  const defaults = REGISTRY_DEFAULTS[name];
  if (!defaults) return null;
  return defaults[themeKind] || null;
}

Behavior is unchanged (defaults[themeKind] || null maps empty-string and null to null, exactly as the old if (value) … else NULL_COLOR did). No new test is added because this is a pure refactor with no behavior change; the existing theme suite (vscode-color-resolver.test.ts and the rest of src/lib/themes/, 48 tests) exercises registryDefaultValue and passes unchanged. tsc -b is clean.

…stry

registryDefault() returned a string-or-NULL_COLOR-symbol that
registryDefaultValue() immediately collapsed back to string | null, and
the symbol never escaped the module (no external consumer imported
NULL_COLOR, ResolvedColor, or registryDefault). Fold the lookup directly
into registryDefaultValue and remove the dead symbol layer. Behavior is
unchanged; existing theme tests (vscode-color-resolver.test.ts et al.)
cover the lookup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: c7e8602
Status: ✅  Deploy successful!
Preview URL: https://1128e25b.mouseterm.pages.dev
Branch Preview URL: https://chore-registry-default-simpl.mouseterm.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant