Open stereodenis opened 1 month 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.
@stereodenis this patch should fix this issue. I will make PR later.
diff --git a/src/layouts/stack.ts b/src/layouts/stack.ts
index 77a9b57c03e1001bb73a7aff171b2cf276d45f0c..024c489843d729031adf09894b319fc96297ee56 100644
--- a/src/layouts/stack.ts
+++ b/src/layouts/stack.ts
@@ -49,7 +49,6 @@ export function horizontalStackLayout(modeConfig: ILayoutConfig = {}) {
rotateZDeg = 30,
} = modeConfig;
- const transform: TransformsStyle["transform"] = [];
const { validLength, value, inputRange } = getCommonVariables({
showLength: showLength!,
value: _value,
@@ -62,12 +61,6 @@ export function horizontalStackLayout(modeConfig: ILayoutConfig = {}) {
snapDirection,
});
- const styles: ViewStyle = {
- transform,
- zIndex,
- opacity,
- };
-
let translateX: number;
let scale: number;
let rotateZ: string;
@@ -112,8 +105,8 @@ export function horizontalStackLayout(modeConfig: ILayoutConfig = {}) {
Extrapolate.CLAMP,
)}deg`;
}
-
- transform.push(
+
+ const transform: TransformsStyle["transform"] = [
{
translateX: translateX!,
},
@@ -122,8 +115,14 @@ export function horizontalStackLayout(modeConfig: ILayoutConfig = {}) {
},
{
rotateZ: rotateZ!,
- },
- );
+ }
+ ];
+
+ const styles: ViewStyle = {
+ transform,
+ zIndex,
+ opacity,
+ };
return styles;
};
@@ -164,7 +163,6 @@ export function verticalStackLayout(modeConfig: ILayoutConfig = {}) {
opacityInterval = 0.1,
rotateZDeg = 30,
} = modeConfig;
- const transform: TransformsStyle["transform"] = [];
const { validLength, value, inputRange } = getCommonVariables({
showLength: showLength!,
value: _value,
@@ -177,12 +175,6 @@ export function verticalStackLayout(modeConfig: ILayoutConfig = {}) {
snapDirection,
});
- const styles: ViewStyle = {
- transform,
- zIndex,
- opacity,
- };
-
let translateX: number;
let scale: number;
let rotateZ: string;
@@ -241,7 +233,7 @@ export function verticalStackLayout(modeConfig: ILayoutConfig = {}) {
);
}
- transform.push(
+ const transform = [
{
translateX: translateX!,
},
@@ -253,8 +245,14 @@ export function verticalStackLayout(modeConfig: ILayoutConfig = {}) {
},
{
translateY: translateY!,
- },
- );
+ }
+ ];
+
+ const styles: ViewStyle = {
+ transform,
+ zIndex,
+ opacity,
+ };
return styles;
};
node_modules/react-native-reanimated-carousel/src/layouts/stack.ts:99