feat: add type-safe KeyId for matchesKey function
- Add KeyId union type covering all valid key combinations
- Add Key helper object for autocomplete (Key.ctrl('c'), Key.escape, etc.)
- Update matchesKey signature to use KeyId instead of string
- Catches typos like 'esacpe' at compile time
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { matchesKey } from "./keys.js";
|
||||
import { type KeyId, matchesKey } from "./keys.js";
|
||||
|
||||
/**
|
||||
* Editor actions that can be bound to keys.
|
||||
@@ -31,10 +31,8 @@ export type EditorAction =
|
||||
// Clipboard
|
||||
| "copy";
|
||||
|
||||
/**
|
||||
* Key identifier string (e.g., "ctrl+c", "shift+ctrl+p", "escape").
|
||||
*/
|
||||
export type KeyId = string;
|
||||
// Re-export KeyId from keys.ts
|
||||
export type { KeyId };
|
||||
|
||||
/**
|
||||
* Editor keybindings configuration.
|
||||
|
||||
Reference in New Issue
Block a user