Skip to content

refactor: migrate ComponentData classes to class fields#8668

Merged
willeastcott merged 2 commits into
mainfrom
refactor/componentdata-class-fields
May 3, 2026
Merged

refactor: migrate ComponentData classes to class fields#8668
willeastcott merged 2 commits into
mainfrom
refactor/componentdata-class-fields

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

Summary

Converts all *ComponentData classes in src/framework/components/*/data.js from constructor-based initialization to ES2022 public class field declarations, matching the style already used by scroll-view and scrollbar.

  • 18 trivial data files (only enabled = true) collapsed to a single class field.
  • ButtonComponentData, CollisionComponentData and ParticleSystemComponentData converted while preserving inline comments, section comments and JSDoc @type annotations.
  • Nullable @type annotations are updated to include |null where the field is initialized to null, so TypeScript validation passes with class-field semantics.

This is a pure internal refactor — no behavioral changes, no public API changes, no renames.

Test plan

  • npm run lint — passes (0 errors; the single pre-existing warning in utils/rollup-build-target.mjs is unrelated).
  • npm test — 1672 tests passing.

Convert all `*ComponentData` classes in `src/framework/components/*/data.js`
from constructor-based initialization to ES2022 public class field
declarations, matching the style already used by `scroll-view` and
`scrollbar`. Nullable `@type` annotations are updated to include `|null`
where fields are initialized to `null`.

Co-authored-by: Cursor <cursoragent@cursor.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

This PR refactors framework component data containers to use ES2022 public class fields instead of constructor-based initialization, aligning the remaining *ComponentData classes with the style already used elsewhere in the component system. In the broader codebase, these classes are instantiated by ComponentSystem.addComponent() as default data holders, so the change is primarily about syntax and typing clarity rather than behavior.

Changes:

  • Replaced trivial constructors in many *ComponentData classes with a single enabled = true class field.
  • Converted the richer ButtonComponentData, CollisionComponentData, and ParticleSystemComponentData classes from constructor assignments to field declarations while preserving defaults and comments.
  • Updated nullable JSDoc annotations on class fields where properties are initialized to null, improving type-checking consistency.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/framework/components/zone/data.js Replaces constructor default with class field for enabled.
src/framework/components/sprite/data.js Replaces constructor default with class field for enabled.
src/framework/components/sound/data.js Replaces constructor default with class field for enabled.
src/framework/components/script/data.js Replaces constructor default with class field for enabled.
src/framework/components/screen/data.js Replaces constructor default with class field for enabled.
src/framework/components/rigid-body/data.js Replaces constructor default with class field for enabled.
src/framework/components/render/data.js Replaces constructor default with class field for enabled.
src/framework/components/particle-system/data.js Converts all particle-system defaults and nullable JSDoc annotations to class fields.
src/framework/components/model/data.js Replaces constructor default with class field for enabled.
src/framework/components/light/data.js Replaces constructor default with class field for enabled.
src/framework/components/layout-group/data.js Replaces constructor default with class field for enabled.
src/framework/components/layout-child/data.js Replaces constructor default with class field for enabled.
src/framework/components/joint/data.js Replaces constructor default with class field for enabled.
src/framework/components/gsplat/data.js Replaces constructor default with class field for enabled.
src/framework/components/element/data.js Replaces constructor default with class field for enabled.
src/framework/components/collision/data.js Converts collision defaults and nullable asset/model typings to class fields.
src/framework/components/camera/data.js Replaces constructor default with class field for enabled.
src/framework/components/button/data.js Converts button defaults and nullable asset/entity typings to class fields.
src/framework/components/audio-listener/data.js Moves serialized enabled default to a class field while preserving comment intent.
src/framework/components/animation/data.js Replaces constructor default with class field for enabled.
src/framework/components/anim/data.js Replaces constructor default with class field for enabled.

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

@willeastcott willeastcott merged commit 965c5a9 into main May 3, 2026
8 checks passed
@willeastcott willeastcott deleted the refactor/componentdata-class-fields branch May 3, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants