All files / src/types tinykeys.d.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                         
/**
 * Workaround for tinykeys v3.0.0 incomplete `exports` map.
 *
 * The package ships `dist/tinykeys.d.ts` and declares `"types": "dist/tinykeys.d.ts"`
 * in `package.json`, but the `exports` field does not include a `types` condition:
 *
 *   "exports": {
 *     ".": {
 *       "import": "./dist/tinykeys.module.js",
 *       "require": "./dist/tinykeys.js"
 *     }
 *   }
 *
 * With `moduleResolution: "bundler"` (Vite+ default), TypeScript resolves imports
 * through `exports` and ignores the legacy `"types"` field. Because there is no
 * `types` condition in `exports`, TypeScript cannot find the declaration file and
 * falls back to `any`. This file restores type safety until tinykeys fixes its
 * package.json.
 */
declare module "tinykeys" {
  export interface KeyBindingMap {
    [keybinding: string]: (event: KeyboardEvent) => void;
  }
 
  export interface KeyBindingHandlerOptions {
    timeout?: number;
  }
 
  export interface KeyBindingOptions extends KeyBindingHandlerOptions {
    event?: "keydown" | "keyup";
    capture?: boolean;
  }
 
  export function parseKeybinding(str: string): unknown[];
  export function createKeybindingsHandler(
    keyBindingMap: KeyBindingMap,
    options?: KeyBindingHandlerOptions,
  ): EventListener;
  export function tinykeys(
    target: Window | HTMLElement,
    keyBindingMap: KeyBindingMap,
    options?: KeyBindingOptions,
  ): () => void;
}