Skip to content

Commit

Permalink
fix: revert constructor options changes and replace never with unknow…
Browse files Browse the repository at this point in the history
…n for composition
  • Loading branch information
thejustinwalsh authored and trezy committed Aug 14, 2024
1 parent aebce41 commit baa1fe4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/typedefs/ConstructorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import type { ConstructorOverrides } from './ConstructorOverrides';
* @see https://github.com/pixijs/pixi-react/issues/500
*/
export type ConstructorOptions<T extends new (...args: any[]) => any> =
T extends new (...args: any[]) => infer Instance
? Instance extends keyof ConstructorOverrides
? ConstructorOverrides[Instance]
: ConstructorParameters<T>[0]
Extract<ConstructorOverrides, { 0: T }> extends [T, infer R]
? unknown extends R
? ConstructorParameters<T>[0]
: R
: unknown;

3 changes: 1 addition & 2 deletions src/typedefs/ConstructorOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ export type ConstructorOverrides =
| [typeof DisplacementFilter, DisplacementFilterOptions]
| [typeof Filter, FilterOptions]
| [typeof NoiseFilter, NoiseFilterOptions]
| [typeof Text, TextOptions]
| unknown;
| [typeof Text, TextOptions];
6 changes: 5 additions & 1 deletion test/unit/typedefs/PixiElements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ describe('PixiElements', () =>
<graphics draw={(_: Graphics) => { /* noop */ }} />
<sprite texture={Texture.EMPTY} />
<alphaFilter alpha={0.5} />
<pixiText anchor={{ x: 0.5, y: 0.5 }} text="Hello, World!" />
</container>
);

expect(elements.props.children).to.have.length(3);
expect(elements.props.children).to.have.length(4);

expect(elements.props.children[0].type).to.equal('graphics');
expect(elements.props.children[0].props.draw).to.be.a('function');
Expand All @@ -27,5 +28,8 @@ describe('PixiElements', () =>

expect(elements.props.children[2].type).to.equal('alphaFilter');
expect(elements.props.children[2].props.alpha).to.equal(0.5);

expect(elements.props.children[3].type).to.equal('pixiText');
expect(elements.props.children[3].props.text).to.equal('Hello, World!');
});
});

0 comments on commit baa1fe4

Please sign in to comment.