Skip to content

Commit 7bb8381

Browse files
authored
Fix typechecking for reanimated>1.4.0 (#165)
See issue #164 Some additional type annotations were needed to pass the typescript checks under various versions of typescript & react-native-reanimated. Notes: I tried to maintain current patterns, but there are alternative approaches: prevMaster could have been annotated an Animated.Value<GestureState> on line 548 , instead of Value<number>. Might be more explicit? Rather than const variable: Animated.Value<number> = new Value(0), the value constructor could be annotated: e.g. const variable = new Value<number>(0). More concise, but again I kept current patterns. I ignored precommit hook warnings (prettier formatting), since I did not think it appropriate to alter many lines It's odd that different versions of typescript + reanimated + gesture-handler have different type inference behavior, but this was the minimal change needed to support a variety of recent TS & reanimated versions.
1 parent 9d97690 commit 7bb8381

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
310310
private panState = new Value(0)
311311
private tapState = new Value(0)
312312
private velocity = new Value(0)
313-
private panMasterState = new Value(GestureState.END)
313+
private panMasterState: Animated.Value<number> = new Value(GestureState.END)
314314
private masterVelocity = new Value(0)
315315
private isManuallySetValue: Animated.Value<number> = new Value(0)
316316
private manuallySetValue = new Value(0)
@@ -543,8 +543,8 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
543543
const limitedVal = new Value(0)
544544
const diffPres = new Value(0)
545545
const flagWasRunSpring = new Value(0)
546-
const justEndedIfEnded = new Value(1)
547-
const wasEndedMasterAfterInner = new Value(1)
546+
const justEndedIfEnded: Animated.Value<number> = new Value(1)
547+
const wasEndedMasterAfterInner: Animated.Value<number> = new Value(1)
548548
const prevMaster = new Value(1)
549549
const prevState = new Value(0)
550550
const rev = new Value(0)

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,9 +3814,9 @@ react-native-gesture-handler@^1.1.0:
38143814
prop-types "^15.5.10"
38153815

38163816
react-native-reanimated@^1.0.1:
3817-
version "1.0.1"
3818-
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.0.1.tgz#5ecb6a2f6dad0351077ac9b771ca943b7ad6feda"
3819-
integrity sha512-RENoo6/sJc3FApP7vJ1Js7WyDuTVh97bbr5aMjJyw3kqpR2/JDHyL/dQFfOvSSAc+VjitpR9/CfPPad7tLRiIA==
3817+
version "1.7.0"
3818+
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.7.0.tgz#896db2576552ac59d288a1f6c7f00afc171f240c"
3819+
integrity sha512-FQWSqP605eQVJumuK2HpR+7heF0ZI+qfy4jNguv3Xv8nPFHeIgZaRTXHCEQL2AcuSIj50zy8jGJf5l134QMQWQ==
38203820

38213821
react-proxy@^1.1.7:
38223822
version "1.1.8"

0 commit comments

Comments
 (0)