Skip to content

Commit

Permalink
Merge pull request #561 from pixijs/fix-constructor-options
Browse files Browse the repository at this point in the history
fix: Remove union types from ConstructorOptions
  • Loading branch information
trezy authored Jan 4, 2025
2 parents 2f18915 + 814a351 commit 68e1190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/typedefs/ConstructorOptions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { type GraphicsContext, type Texture } from 'pixi.js';
import { type ConstructorOverrides } from './ConstructorOverrides';

type ConstructorOptionExcludes = GraphicsContext | Texture;

/**
* We're adding a specific options type overrides for some components because their deprecated overloads get in the way.
* @see https://github.com/pixijs/pixi-react/issues/500
*/
export type ConstructorOptions<T extends new (...args: any[]) => any> =
Extract<ConstructorOverrides, { 0: T }> extends [T, infer R]
? unknown extends R
? ConstructorParameters<T>[0]
? NonNullable<Exclude<ConstructorParameters<T>[0], ConstructorOptionExcludes>>
: R
: unknown;
5 changes: 2 additions & 3 deletions src/typedefs/ConstructorOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
type PlaneGeometryOptions,
type Text,
type TextOptions,
type Texture,
type TilingSprite,
type TilingSpriteOptions,
} from 'pixi.js';
Expand All @@ -28,8 +27,8 @@ export type ConstructorOverrides =
| [typeof HTMLText, HTMLTextOptions]
| [typeof Mesh, MeshOptions]
| [typeof MeshGeometry, MeshGeometryOptions]
| [typeof NineSliceSprite, NineSliceSpriteOptions | Texture]
| [typeof NineSliceSprite, NineSliceSpriteOptions]
| [typeof PlaneGeometry, PlaneGeometryOptions]
| [typeof TilingSprite, TilingSpriteOptions | Texture]
| [typeof TilingSprite, TilingSpriteOptions]
| [typeof Text, TextOptions];

0 comments on commit 68e1190

Please sign in to comment.