Closed trezy closed 3 months ago
Fixed in 8.0.0-dev.6b268b5
.
On v9.beta13 react treats text
tags as React.SVGTextElementAttributes<SVGTextElement>
tried to override the default type for JSX.IntrinsicElements.tex
but cannot resolve PixiReactElementProps type
declare namespace JSX {
interface IntrinsicElements {
['text']: PixiReactElementProps<typeof Text>
}
}
@trezy fixed adding the following pixi.d.ts
file to project
// pixi.d.ts
declare namespace JSX {
interface IntrinsicElements {
"text": import('pixi.js').TextOptions
}
}
is it worth including it on v9? it types correctly text
on JSX like pixiText
Current Behavior
The
<text>
component throws a type error when using thetext
property.Expected Behavior
The
<text>
component does not throw a type error when using thetext
property.Steps to Reproduce
Environment
@pixi/react
version: 8.0.0-dev.f3abf87pixi.js
version: 8.2.1React
version: 18.3.1ReactDOM
version: 18.3.1Possible Solution
No response
Additional Information
I'm pretty confident the issue is the order of overloads on the
Text
constructor in Pixi.js. When we're dynamically building the types for Pixi React, we can't choose which overload to use. I think Typescript is just picking the last overload (which is deprecated) by default. This overload doesn't acceptTextOptions
as the first property like most other classes, so it doesn't expose the appropriate props on the<text>
copmponent.https://github.com/pixijs/pixijs/blob/dev/src/scene/text/Text.ts#L40-L46