Convert Stage class from JavaScript to TypeScript#1371
Merged
Conversation
- 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>
- 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>
Contributor
There was a problem hiding this comment.
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.jswith a fully typedsrc/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.
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stageclass from.jsto.tswith full type annotationsStageSettingsinterface for constructor optionsonResetEvent/onDestroyEventwithApplicationparameterlight.update()/preDraw()/draw()/postDraw()calls to match actual signatures (previously passing unused extra arguments silently ignored by JS)stage.jstostage.tsTest plan
🤖 Generated with Claude Code