Skip to content

Convert Stage class from JavaScript to TypeScript#1371

Merged
obiot merged 3 commits intomasterfrom
convert-stage-to-typescript
Apr 11, 2026
Merged

Convert Stage class from JavaScript to TypeScript#1371
obiot merged 3 commits intomasterfrom
convert-stage-to-typescript

Conversation

@obiot
Copy link
Copy Markdown
Member

@obiot obiot commented Apr 11, 2026

Summary

  • Convert Stage class from .js to .ts with full type annotations
  • Add StageSettings interface for constructor options
  • Type onResetEvent/onDestroyEvent with Application parameter
  • Fix light.update()/preDraw()/draw()/postDraw() calls to match actual signatures (previously passing unused extra arguments silently ignored by JS)
  • Update all import paths from stage.js to stage.ts
  • Add Stage-specific unit tests

Test plan

  • All 2371 tests pass (74 test files)
  • New Stage tests cover constructor, settings callbacks, update return value
  • Build compiles with 0 errors

🤖 Generated with Claude Code

- Add proper type annotations for all properties, methods, and parameters
- Type onResetEvent/onDestroyEvent with Application parameter
- Fix light.update()/preDraw()/draw()/postDraw() calls to match actual signatures
  (previously passing unused extra arguments silently ignored by JS)
- Add StageSettings interface for constructor options
- Update all import paths from stage.js to stage.ts
- Add Stage unit tests (constructor, settings callbacks, update return value)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 11, 2026 03:17
- Replace me.state/me.Stage/me.GUI_Object with direct imports in examples
- Update state.change() example to include forceChange parameter
- Use const instead of let in USER constant example
- Remove unused Color import

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Converts the core Stage state object to TypeScript to improve type-safety across the state/event pipeline, updates engine imports accordingly, and adds unit coverage around basic Stage behavior.

Changes:

  • Replace src/state/stage.js with a fully typed src/state/stage.ts (including constructor settings typing and corrected Light2d call signatures).
  • Update internal imports to reference stage.ts (state manager, event system, loader, public index export).
  • Add Stage-focused unit tests in tests/state.spec.js.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/melonjs/tests/state.spec.js Adds unit tests for Stage defaults, settings callbacks, and update return value.
packages/melonjs/src/system/event.ts Updates Stage import path used for event typing.
packages/melonjs/src/state/state.ts Updates Stage import path used by the state manager.
packages/melonjs/src/state/stage.ts New TypeScript implementation of Stage with typed settings, lifecycle, update, and draw logic.
packages/melonjs/src/state/stage.js Removes the legacy JavaScript implementation.
packages/melonjs/src/loader/loadingscreen.js Updates Stage import path used by the default loading screen stage.
packages/melonjs/src/index.ts Updates Stage import path for the public API surface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/melonjs/src/state/stage.ts Outdated
Comment thread packages/melonjs/src/state/stage.ts Outdated
Comment thread packages/melonjs/src/system/event.ts Outdated
Comment thread packages/melonjs/src/state/stage.ts Outdated
- Fix boolean comparisons: use direct truthiness instead of === true/false
- Fix arrow-body-style in tests (block statements for arrow functions)
- Use import type for Stage in event.ts (type-only usage)
- Make app parameter required in onResetEvent/onDestroyEvent signatures
- Type StageSettings.onResetEvent with explicit Application parameter
- Fix typos: renderered → rendered, Renderering → Rendering, reseting → resetting
- Update lights example to use modern import style
- Remove unused Container import comment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@obiot obiot merged commit b662e48 into master Apr 11, 2026
6 checks passed
@obiot obiot deleted the convert-stage-to-typescript branch April 11, 2026 03:36
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.

2 participants