dohooo / react-native-reanimated-carousel

🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)
https://react-native-reanimated-carousel.vercel.app
MIT License
2.73k stars 317 forks source link

Property 'push' does not exist on type #684

Open stereodenis opened 4 days ago

stereodenis commented 4 days ago
Property 'push' does not exist on type 'readonly (({ perspective: AnimatableNumericValue; } & { rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; scaleX?: undefined; ... 5 more ...; matrix?: undefined; }) | ... 11 more ... | ({ ...; } & { ...; }))[]'.

node_modules/react-native-reanimated-carousel/src/layouts/stack.ts:99

dosubot[bot] commented 4 days ago

Hey @stereodenis! I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let's tackle this together!

I found a similar closed issue that might be relevant to your problem: 我完全根据文档例子使用,却报错无法使用。 [1].

The error you're encountering, "Property 'push' does not exist on type...", suggests that the array transform is being treated as a read-only array. The type definition of the array being manipulated in stack.ts:99 is TransformsStyle["transform"] [2].

To resolve this issue, you can try casting the array to a mutable type before using the push method. Here's an example of how you might do this:

const transform: TransformsStyle["transform"] = [] as TransformsStyle["transform"] & { push: any[]["push"] };

This will allow you to use the push method on the transform array without TypeScript throwing an error.

To continue talking to Dosu, mention @dosu.