refactor: remove redundant type casts from slash command handlers#3320
Open
oldschoola wants to merge 1 commit into
Open
refactor: remove redundant type casts from slash command handlers#3320oldschoola wants to merge 1 commit into
oldschoola wants to merge 1 commit into
Conversation
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
roboomp
reviewed
Jun 23, 2026
roboomp
left a comment
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
SettingsAPI is already generically typed:get<P extends SettingPath>(path: P): SettingValue<P>andset<P>(path: P, value: SettingValue<P>). String literals like"browser.enabled"are validSettingPathvalues (keyof Schema), andSettingValue<"browser.enabled">resolves tobooleanvia the conditional type. Theas SettingPathandas booleancasts were redundant — they asserted types TypeScript could already infer.Changes
Removed 16 redundant type assertions from
builtin-registry.ts:as SettingPathon string literal arguments tosettings.get()/settings.set()as booleanonsettings.get()return valuesas SettingValue<SettingPath>onsettings.set()values (this one was doubly wrong — it used the bareSettingPathunion instead of the specific literal)SettingPath, SettingValuetype importTests
bun checkpasses (all 16 packages)