bfirsh / bfirsh/jsnes

TypeScript type definitions are incorrect

Open
#610 0 comments 0 reactions 0 assignees View on GitHub
bug component: browser difficulty: easy priority: medium
Dominant language
JavaScript
Stars
6.4k
Forks
857
PR merge metrics
No merged PRs in 30d

Description

## 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;
// ...
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/nes.d.ts and compare each declaration with the corresponding NES implementation, including the frame callback, emulator data, and available methods. Then inspect gamegenie.js to define its missing TypeScript declaration. Done means the declarations match the runtime APIs, including the GameGenie property, without exposing the nonexistent stop() method.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.