Open zOadT opened 1 year ago
I shortly looked into it: The problem seems to be that style has different types for the getter and setter:
// @pixi/text/lib/Text.d.ts
get style(): TextStyle;
set style(style: TextStyle | Partial<ITextStyle>);
There are Issues in the typescript repo that indicate that it is currently not possible to receive the type of the setters, so it seems like we have to manually adjust the type in our types :worried:
In case someone else runs into this: As a workaround you can define a .d.ts
file locally with the content
import type { IPointData, ITextStyle, TextStyle } from 'pixi.js'
declare module 'react-pixi-fiber' {
interface PixiComponent<P = {}> {
(props: Setters<PixiElement<P>>): React.ReactElement<P>;
}
type Override<P, E> = Omit<P, keyof E> & Partial<E>
type Setters<P> = P extends Text
? Override<P, {
text: string | number;
style: TextStyle | Partial<ITextStyle>;
}>
: P extends TilingSprite
? Override<P, {
tileScale: IPointData;
}>
: P;
}
Definitively not a clean solution, but I don't think we want explicit type information in the typings of this library.
Description
Since pixi.js 7.1 the type of
Text.style
isPIXI.TextStyle | Partial<PIXI.ITextStyle>
. But pix-react-fiber only allows to setPIXI.TextStyle
objects as style attribute (since 7.1 every property is required inPIXI.TextStyle
)Steps to reproduce
Additional info