Skip to content

Commit 68e1190

Browse files
authored
Merge pull request #561 from pixijs/fix-constructor-options
fix: Remove union types from ConstructorOptions
2 parents 2f18915 + 814a351 commit 68e1190

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/typedefs/ConstructorOptions.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { type GraphicsContext, type Texture } from 'pixi.js';
12
import { type ConstructorOverrides } from './ConstructorOverrides';
23

4+
type ConstructorOptionExcludes = GraphicsContext | Texture;
5+
36
/**
47
* We're adding a specific options type overrides for some components because their deprecated overloads get in the way.
58
* @see https://github.com/pixijs/pixi-react/issues/500
69
*/
710
export type ConstructorOptions<T extends new (...args: any[]) => any> =
811
Extract<ConstructorOverrides, { 0: T }> extends [T, infer R]
912
? unknown extends R
10-
? ConstructorParameters<T>[0]
13+
? NonNullable<Exclude<ConstructorParameters<T>[0], ConstructorOptionExcludes>>
1114
: R
1215
: unknown;

src/typedefs/ConstructorOverrides.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
type PlaneGeometryOptions,
1717
type Text,
1818
type TextOptions,
19-
type Texture,
2019
type TilingSprite,
2120
type TilingSpriteOptions,
2221
} from 'pixi.js';
@@ -28,8 +27,8 @@ export type ConstructorOverrides =
2827
| [typeof HTMLText, HTMLTextOptions]
2928
| [typeof Mesh, MeshOptions]
3029
| [typeof MeshGeometry, MeshGeometryOptions]
31-
| [typeof NineSliceSprite, NineSliceSpriteOptions | Texture]
30+
| [typeof NineSliceSprite, NineSliceSpriteOptions]
3231
| [typeof PlaneGeometry, PlaneGeometryOptions]
33-
| [typeof TilingSprite, TilingSpriteOptions | Texture]
32+
| [typeof TilingSprite, TilingSpriteOptions]
3433
| [typeof Text, TextOptions];
3534

0 commit comments

Comments
 (0)