Skip to content

refactor: convert source files to Typescript with minimal changes#116

Draft
jannone wants to merge 138 commits intoppeccin:masterfrom
jannone:feat/typescript-conversion
Draft

refactor: convert source files to Typescript with minimal changes#116
jannone wants to merge 138 commits intoppeccin:masterfrom
jannone:feat/typescript-conversion

Conversation

@jannone
Copy link

@jannone jannone commented Jan 23, 2026

  • Rename all source files from .js to .ts (except for compressed, system files)
  • Remove ZIP.js file and include JSZip 2.x package instead
  • Make just enough changes to satisfy tsc

jannone and others added 30 commits January 22, 2026 15:32
Created src/main/globals.d.ts with declare var wmsx: any
to fix all "Cannot find name 'wmsx'" TypeScript errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Make channel5 initialization consistent with channel1-4 by using 0 instead
of false. The setMixer function assigns numbers (1 or 0) to all channels,
so the type must match.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…eassignment

In TypeScript, functions declared with the `function` statement cannot be
reassigned. These R800 timing functions needed to be reassignable based on
the r800Timing configuration value.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
TypeScript requires explicit number types for arithmetic operations.
JavaScript implicitly converts booleans to 0/1, but TypeScript doesn't
allow this. Used Number() wrapper for all boolean-to-number coercions
in CPU flag calculations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… loops

The variable `i` was declared in a for-in loop which made it a string type.
Subsequent numeric for loops at lines 3023, 3031, 3039 tried to use `i` as a
number, causing TypeScript type errors. Use a new `idx` variable for these
numeric loops to avoid the string/number type conflict.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e inference

Refactor defineInstruction() to compute all values as local variables first,
then create the object with all properties at once. This allows TypeScript
to infer the complete type instead of inferring `{}` from the empty object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of calling success() and then adding the A property afterward,
return a complete object literal with F, extraIterations, and A properties.
This satisfies TypeScript's type inference which doesn't allow adding
properties to an object after creation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The INIHRD function was defined with (F, HL) parameters but they were
never used in the function body. This caused TS2554 error when calling
INIHRD() with no arguments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The alternateSpeed variable was declared as `false` but assigned number
values (SPEED_FAST=10, SPEED_SLOW=0.3) and null throughout the code.
Changed initialization from `false` to `null` with explicit type annotation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move vy, pw, up, upf properties into the initial object literal with
conditional values based on extended parameter, instead of adding them
conditionally afterward.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of adding the 'v' property after object creation, include
it in the initial object literal to satisfy TypeScript's type
inference. This allows TypeScript to infer the complete type
including the version property.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed cloneInfo function to use spread operator with conditional
object spreading instead of creating empty object and assigning
properties. This satisfies TypeScript's type inference while
preserving the exact behavior of only including truthy properties.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Error: Expected 4 arguments, but got 3 (TS2554)
- Location: ColorCache.ts lines 26, 36, 45, 54, 75, 87
- Solution: Changed function hexValue(b, g, r, a) to function hexValue(b, g, r, a = 1)
- Result: Fixed 6 TS2554 errors in ColorCache.ts
- Remaining errors: 488 (down from 500, 12 errors fixed)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Make the forceRenderMetrics parameter in V9990.updateMode optional
with a default value of false.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jannone and others added 30 commits January 22, 2026 23:05
Extended Element, HTMLElement, EventTarget, and File interfaces with
custom wmsx* properties used throughout the codebase for UI state
tracking and event handling. These properties are dynamically added
to DOM elements at runtime for features like menu handling, button
state, virtual keyboard mapping, and file loading progress.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Made touch parameter optional with false default in barMenuItemSetActive
function in CanvasDisplay.ts. The function is called from multiple
locations with varying arguments: some pass both element and touch
(e.g., line 1617 with true, lines 1644/1648 with event type check),
while most pass only element (lines 1652, 1664, 1702, 1889, 1988, 2047).

The touch parameter controls haptic feedback and touch activation timing.
When not provided, it should default to false (no touch interaction).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed `secSlot |= true` to `secSlot = true` in barMenuItemTouchEndOrMouseUp.
TypeScript requires arithmetic operations to use numeric types, not booleans.
Since the intent is to set secSlot to true when touch activation exceeds the
threshold, a simple assignment is clearer and correct.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extended Document interface with exitFullscreen methods and fullscreenElement
properties for standard and vendor-prefixed (webkit, moz) Fullscreen API.
Extended Element and HTMLElement interfaces with requestFullscreen methods
for standard and vendor-prefixed (webkit, moz) APIs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added missing third parameter (resizeWindow: false) to auxDisplayScale
call in auxReadjustAll function line 2169. When the auxiliary window is
maximized or being adjusted by window size, the window should not be
resized programmatically, hence passing false.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added optional standalone property to Navigator interface in globals.d.ts
for Safari iOS PWA detection. This property indicates whether the web app
is running in standalone mode (saved to home screen).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extended Window interface with webkitAudioContext and WebkitAudioContext
properties for legacy Safari/WebKit browser support. These vendor prefixes
were used before the Web Audio API was standardized. The codebase checks
for standard AudioContext first, then falls back to prefixed versions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed (add | 0) to Number(add) for array indexing in line 36.
The add variable comes from for...in loop iteration over diff.diffs
object keys, making it a string type. Bitwise OR operation requires
numeric operands in TypeScript. Using Number() explicitly converts
the string key to a number for array indexing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Instead of calling req.onerror() without arguments (which TypeScript
expects to receive an event parameter), directly call loadError()
with the same error information. This maintains the same behavior
while satisfying TypeScript's type requirements for event handlers.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added type assertion to event.target.result in onload handler.
FileReader.readAsArrayBuffer() guarantees result is ArrayBuffer, but
TypeScript types it as string | ArrayBuffer union since different read
methods return different types.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extended Navigator interface in globals.d.ts with IE/legacy browser
properties: userLanguage (IE-specific language detection) and
msMaxTouchPoints (MS-prefixed touch points). Used in Util.ts for
backward-compatible language detection and touch device detection.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant