Skip to content

Conversation

ch1ll0ut1
Copy link
Contributor

Description of change

Update Container.parent type from Container to Container | null to match the actual runtime behavior where parent can be null when a container is not attached to a parent.
Why necessary: The current type forces developers to use non-null assertions (!) or disable ESLint warnings when checking if a container has a parent, even though the runtime value can legitimately be null.
Example:

// Current behavior requires non-null assertion or ESLint disable
let current = sprite;
while (current.parent!) { // ESLint: Unnecessary non-null assertion
    current = current.parent!;
}

// With the fix, natural null checking works
let current = sprite;
while (current.parent) { // Clean, no ESLint warnings
    current = current.parent;
}

This change aligns the TypeScript types with the actual runtime behavior where parent is initialized as null and can be null when containers are detached from their parent.

Pre-Merge Checklist
  • Lint process passed (npm run lint)
  • [-] Tests passed (npm run test) (the current dev branch seems to have many failing tests, I dont think its related)

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2b8b40f:

Sandbox Source
pixi.js-sandbox Configuration

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

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

Thank you!

@Zyie Zyie changed the title Fix Container.parent type not being nullable and possibly undefined fix: Container.parent type not being nullable and possibly undefined Jul 21, 2025
@Zyie Zyie added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Jul 21, 2025
@Zyie Zyie added this pull request to the merge queue Jul 23, 2025
Merged via the queue into pixijs:dev with commit 8182e30 Jul 23, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants