Closed leethree closed 2 years ago
I'm still having this issue on v12.4.3
. It seems that the missing types are also affecting other type inferences. For example, if I try to create an animated component of Circle
the resulting component props are not inferred from ComponentType<CircleProps>
, instead it only uses typeof Circle
.
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
// ^ type: Animated.AnimatedComponent<typeof Circle>
<AnimatedCircle r={10} cx={0} cy={0} />
// ^ error: all props are unknow
SvgProps
also missing
When trying to bump to 12.4.3
I started getting type errors for transform
, using it like transform={[{ rotate: '180deg' }]}
. When I tried changing it to the newly requested types to remove the typescript errors, none of the rotations worked anymore, so I decided to hold off on bumping the version. I wonder if this is related?
TransformObject export also seems to have moved. We're now needing to import it via:
import { TransformObject } from 'react-native-svg/src/lib/extract/types';
rather than directly from 'react-native-svg'
.
@ginnymin could you post a reproduction that shows the regression of transform
prop? Problems mentioned here should be solved by https://github.com/react-native-svg/react-native-svg/pull/1829 since we now export the types that were available before.
@ginnymin the problem you mentioned might be caused by this line: https://github.com/react-native-svg/react-native-svg/blob/6d1110b9c06742ebdcf09d0e16b9921a22735777/src/lib/extract/types.ts#L209 and I am not sure how to fix this correctly. Reproduction would help with this for sure.
@WoLewicki I ended up working around the TS issue by appending the transform to styles instead. I'll see if the original issue is still happening after I try the recent release. I was basically just using the transform prop on an SvgXml implementation. If I tried using the new transform types, the TS error went away but the transform wouldn't be rendered (I specifically was just doing a rotation)
@ginnymin It would be best to have a reproduction of this so it is easy to spot the exact problem.
I'm experiencing this. I'm using the moduleSuffixes
tsconfig compiler option. I think it's due to differences in type exports between ReactNativeSVG.ts
and ReactNativeSVG.web.ts
Bug
A few type exports are missing since v12.4.1. I think the exported types shouldn't change as it's a patch release.
Unexpected behavior
NumberProp
no longer exists from the exports.TextAnchor
andAlignmentBaseline
are also missing.Environment info
React native info output:
Library version: 12.4.3
Steps To Reproduce
Try import
NumberProp
and you'll see typescript error: