#610·jsnes

TypeScript type definitions are incorrect

Author: bfirshCreated Feb 28, 2026Updated Feb 28, 2026
Labelsbugpriority: mediumdifficulty: easycomponent: browser

Summary

Several issues in src/nes.d.ts:

  1. onFrame callback types Buffer (line 11) but the actual frame buffer is a Uint32Array (or a plain number[]). Using Buffer (a Node.js type) is wrong for both browser and Node environments.

  2. EmulatorData types all properties as string (lines 3-8) but they're objects returned by toJSON() on CPU, PPU, PAPU, and mapper.

  3. Declares stop() method (line 21) that doesn't exist on the NES class.

  4. Missing GameGenie type declarations — no .d.ts file for gamegenie.js.

Fix

typescript
export interface EmulatorData {
  cpu: object;
  mmap: object;
  ppu: object;
  papu: object;
}

export interface NESOptions {
  onFrame?: (buffer: Uint32Array) => void;
  // ...
}

export class NES {
  // Remove stop(), it doesn't exist
  // Add gameGenie property
  gameGenie: GameGenie;
  // ...
}