getChildByName is set as optional in v6
See original GitHub issueUpdating 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:
- Is the
getChildByName
not always guaranteed to be defined and the typing is correct, or not? - What’s the reasoning behind the
GlobalMixins
and why wasgetChildByName
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, but since the typings is declared in the mixin package, it shouldn’t be optional.
@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.