Commit 1000036
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: Tyler Gray <tylerg@emergentsoftware.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 87846ef commit 1000036
1 file changed
Lines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
3 | 11 | | |
4 | 12 | | |
5 | 13 | | |
| |||
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
92 | | - | |
93 | | - | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
| |||
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
137 | | - | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
148 | | - | |
| 156 | + | |
149 | 157 | | |
150 | 158 | | |
151 | 159 | | |
| |||
191 | 199 | | |
192 | 200 | | |
193 | 201 | | |
194 | | - | |
| 202 | + | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
| |||
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
204 | | - | |
| 212 | + | |
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
| |||
302 | 310 | | |
303 | 311 | | |
304 | 312 | | |
305 | | - | |
| 313 | + | |
306 | 314 | | |
307 | 315 | | |
308 | 316 | | |
0 commit comments