Skip to content

refactor: remove redundant type casts from slash command handlers#3320

Open
oldschoola wants to merge 1 commit into
can1357:mainfrom
oldschoola:refactor/remove-redundant-settingpath-casts
Open

refactor: remove redundant type casts from slash command handlers#3320
oldschoola wants to merge 1 commit into
can1357:mainfrom
oldschoola:refactor/remove-redundant-settingpath-casts

Conversation

@oldschoola

Copy link
Copy Markdown
Contributor

Problem

The Settings API is already generically typed: get<P extends SettingPath>(path: P): SettingValue<P> and set<P>(path: P, value: SettingValue<P>). String literals like "browser.enabled" are valid SettingPath values (keyof Schema), and SettingValue<"browser.enabled"> resolves to boolean via the conditional type. The as SettingPath and as boolean casts were redundant — they asserted types TypeScript could already infer.

Changes

Removed 16 redundant type assertions from builtin-registry.ts:

  • 10× as SettingPath on string literal arguments to settings.get()/settings.set()
  • as boolean on settings.get() return values
  • as SettingValue<SettingPath> on settings.set() values (this one was doubly wrong — it used the bare SettingPath union instead of the specific literal)
  • Unused SettingPath, SettingValue type import

Tests

  • bun check passes (all 16 packages)
  • Slash command tests pass (6/6)

The Settings API is already generically typed: get<P extends
SettingPath>(path: P): SettingValue<P> and set<P>(path: P, value:
SettingValue<P>). String literals like 'browser.enabled' are valid
SettingPath values (keyof Schema), and SettingValue<'browser.enabled'>
resolves to boolean via the conditional type.

Removed 16 redundant casts from builtin-registry.ts:
- 10x 'as SettingPath' on string literal arguments
- 4x 'as boolean' on settings.get() return values
- 2x 'as SettingValue<SettingPath>' on settings.set() values
- Unused 'SettingPath, SettingValue' type import
@github-actions github-actions Bot added the vouched Passed the vouch gate label Jun 23, 2026
@roboomp roboomp added cli CLI commands and arguments refactor review:p0 triaged labels Jun 23, 2026

@roboomp roboomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 / lgtm: the diff is a tight refactor in builtin-registry.ts, and Settings.get/set infer the literal setting paths as claimed.
No inline findings. bun check passed. Targeted bun test packages/coding-agent/test/acp-builtins.test.ts did not start because this worktree lacks packages/coding-agent/src/export/html/tool-views.generated.js, so I did not count that as a PR regression.
Thanks for the cleanup.

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

Labels

cli CLI commands and arguments refactor review:p0 triaged vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants