pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.25k stars 173 forks source link

Fix typings for sprite with children #409

Closed Hogar closed 1 year ago

Hogar commented 1 year ago

Fix typings for Sprite with children. For example this code:

<Container x={100} y={100}>
  <Sprite texture={Assets.cache.get('/assets/texture.png')} scale={new Point(0.4, 0.4)}>
    <Text
      text="I am text as sprite's child"
      style={new TextStyle({ fill: 0xffffff })}
    />
  </Sprite>
</Container>

generates Sprite type error: Type '{ children: Element; texture: Texture<Resource>; scale: Point; }' is not assignable to type 'IntrinsicAttributes & Partial<Omit<Sprite, P | ReadonlyKeys<Sprite> | keyof WithSource> & WithPointLike<P>> & WithSource & InteractionEvents & { ...; }'.   Property 'children' does not exist on type 'IntrinsicAttributes & Partial<Omit<Sprite, P | ReadonlyKeys<Sprite> | keyof WithSource> & WithPointLike<P>> & WithSource & InteractionEvents & { ...; }'.

baseten commented 1 year ago

@Hogar can this not be solved in the same was it was done for Container?

ie.

export const Sprite: React.FC<React.PropsWithChildren<_ReactPixi.ISprite>>;
baseten commented 1 year ago

Also please merge/rebase the latest changes on master for .codesandbox/ci.json 🙏

codesandbox-ci[bot] commented 1 year ago

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 4d581a44451575ce99192d0cd2bf5032ccbe65f9:

Sandbox Source
sandbox Configuration
Hogar commented 1 year ago

@Hogar can this not be solved in the same was it was done for Container?

ie.

export const Sprite: React.FC<React.PropsWithChildren<_ReactPixi.ISprite>>;

Thanks for idea, i made the changes ;)

baseten commented 1 year ago

@Hogar I suspect a similar change is also required for ParticleContainer would you mind adding it to this PR?

Hogar commented 1 year ago

@Hogar I suspect a similar change is also required for ParticleContainer would you mind adding it to this PR?

Done.