question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getChildByName is set as optional in v6

See original GitHub issue

Updating to pixi v6 we’ve run in to a minor issue. The method getChildByName on Container is set as optional. Is this method (and other attributes added via GlobalMixins) actually undefined at any point, or is the typing wrong? We’re using the method frequently in our code base and it’s tedious to add falsy checks everywhere. If it’s actually not guaranteed to be defined, then we will of course do the checks, but I suspect that it’s actually always defined.

Also, I don’t understand why the method is moved to a mixin and not defined on the class directly as it was in v5.

In summary, this boils down to two questions:

  1. Is the getChildByName not always guaranteed to be defined and the typing is correct, or not?
  2. What’s the reasoning behind the GlobalMixins and why was getChildByName moved there in v6?

Thanks in advance!

// https://github.com/pixijs/pixi.js/blob/dev/packages/mixin-get-child-by-name/global.d.ts
declare namespace GlobalMixins
{
    interface DisplayObject
    {
        name?: string;
    }

    interface Container
    {
        getChildByName?(name: string, isRecursive?: boolean): import('@pixi/display').DisplayObject;
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ShukantPalcommented, Apr 25, 2021

Yeah, but since the typings is declared in the mixin package, it shouldn’t be optional.

1reaction
bigtimebuddycommented, Apr 26, 2021

@ivanpopelyshev Each mixin package has own local global.d.ts file. These typings should definitely not be optional. I believe this probably an artifact of the development of the GlobalMixins and moving stuff around. If you’re installing @pixi/mixin-get-child-by-name this is expected behavior.

This should look more like the Application plugins, for instance: https://github.com/pixijs/pixi.js/blob/8c42699aae78199a4cfd1feeef6dc862afd724fe/packages/ticker/global.d.ts#L1-L15

I believe @MrEmanuel is correct here. There are likely other places this occurs too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PIXI.Container - PixiJS API Documentation
Container is a general-purpose display object that holds children. It also adds built-in support for advanced rendering features like ...
Read more >
Getting "Error #1006: getChildByName is not a function" when ...
getChildByName ("tooltip_text") as TextField).text="being set automatically"; ... SimpleButton class does not have getChildByName function.
Read more >
Scene Graph View — Katana Developer Guide - Foundry Learn
You can find a complete set of examples using the SceneGraphView widget in ... Specifying the column title display text and optional icon....
Read more >
Untitled
Stephen amell casey jones set photos, Ferme basse cour arnouville, ... Roilo ferar nimontron last episode, Optional parameters in c# interface, ...
Read more >
Untitled
Calibra v6 engine mounts! ... Electric zoo live sets soundcloud. ... Nghe nhac rock viet hay, Eurovision stage set 2013, Parker's back? Ondas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found