Skip to content

fix(types): close 6 svelte-check errors — keybindings test Input cast (#214 Group E)#236

Merged
tylergraydev merged 1 commit into
mainfrom
fix/ts-errors-keybindings-input-context
May 16, 2026
Merged

fix(types): close 6 svelte-check errors — keybindings test Input cast (#214 Group E)#236
tylergraydev merged 1 commit into
mainfrom
fix/ts-errors-keybindings-input-context

Conversation

@tylergraydev

Copy link
Copy Markdown
Owner

Part of the #214 cleanup. Brings npm run check from 53 → 47 errors (closes 6). Test-only change, no production behavior.

What was wrong

keybindingsLibrary.test.ts mocks $lib/types (lines 4–21) to provide a minimal universe with an extra 'Input' context and a 'newline' action — that's how the conflict-detection tests have something cross-context to exercise (e.g. detectConflicts('Global', 'Shift+Enter') expects an Input conflict, where newline defaults to Shift+Enter).

vi.mock is runtime-only, so TypeScript still reads the real KeybindingContext union from $lib/types, which doesn't include 'Input'. The store methods are typed (context: KeybindingContext, …) so the 6 test sites passing 'Input' errored.

Fix

Imported KeybindingContext and added one cast alias at the top of the file:

const Input = 'Input' as unknown as KeybindingContext;

Replaced the 6 'Input' literals at the call sites typed against KeybindingContext (setBinding, detectConflicts, Map.has, binding.context comparison). A comment explains why the cast is needed so future readers don't try to delete it.

Decision: don't add 'Input' to the production union

That would be a phantom value — nothing in the real KEYBINDING_CONTEXTS or KEYBINDING_ACTIONS uses it; it only exists in this test's mock. Same principle as #221's spinnerverbs decision: don't make production types lie to accommodate a test.

Test plan

  • npm run check — 47 errors (down from 53 on main)
  • npx vitest run keybindingsLibrary — 31/31 pass

🤖 Generated with Claude Code

…#214 Group E)

Part of the #214 cleanup. Brings `npm run check` from 53 -> 47 errors
(closes 6). Test-only change, no production behavior.

## What was wrong

`keybindingsLibrary.test.ts` mocks `$lib/types` (lines 4-21) to provide
a minimal universe with an extra `'Input'` context and a `'newline'`
action — that's how the conflict-detection tests have something
cross-context to exercise (e.g. `detectConflicts('Global', 'Shift+Enter')`
expects an `Input` conflict, where `newline` defaults to `Shift+Enter`).

`vi.mock` is runtime-only, so TypeScript still reads the real
`KeybindingContext` union from `$lib/types`, which doesn't include
`'Input'`. The store methods are typed `(context: KeybindingContext, ...)`
so the 6 test sites passing `'Input'` errored.

## Fix

Imported `KeybindingContext` and added one cast alias at the top of
the file:

    const Input = 'Input' as unknown as KeybindingContext;

Replaced the 6 `'Input'` literals at call sites typed against
`KeybindingContext` (setBinding, detectConflicts, Map.has,
binding.context comparison). Comment explains why the cast is needed
so future readers don't try to delete it.

NOT adding `'Input'` to the production `KeybindingContext` union —
that would be a phantom value (nothing in real `KEYBINDING_CONTEXTS`
or `KEYBINDING_ACTIONS` uses it; it only exists in this test's mock).
Same principle as #221's spinnerverbs decision.

## Test plan

- [x] `npm run check` — 47 errors (down from 53 on `main`)
- [x] `npx vitest run keybindingsLibrary` — 31/31 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tylergraydev tylergraydev merged commit 1000036 into main May 16, 2026
10 checks passed
tylergraydev added a commit that referenced this pull request May 16, 2026
Rebased onto current main. The original commit also included fixes
for preexisting type errors across usageStore/skill/invokeMock/etc.,
but main has since landed canonical fixes for all of them (#221, #226,
#227, #236), so those parts of the original commit are dropped.

Net change: WSL2-specific Rust code (utils/wsl.rs, services/wsl_config.rs)
plus the settings/config plumbing to expose WSL editors in the UI.

See PR #149 for full description.
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