Skip to content

fix(typings): fix AnimatableComponent ref type and animate method return signature (#407, #328)#415

Open
hmadhsan wants to merge 1 commit into
oblador:masterfrom
hmadhsan:fix/typings-ref-type-and-animate-return-signature
Open

fix(typings): fix AnimatableComponent ref type and animate method return signature (#407, #328)#415
hmadhsan wants to merge 1 commit into
oblador:masterfrom
hmadhsan:fix/typings-ref-type-and-animate-return-signature

Conversation

@hmadhsan

Copy link
Copy Markdown

Closes #407
Closes #328

🐛 What was the issue?

  1. Ref Type Error (Incorrect ref type #407): AnimatableComponent in typings/react-native-animatable.d.ts extended ClassicComponentClass (a React constructor class type) alongside Component. When developers passed Animatable.View or Animatable.Text to useRef<Animatable.View>(null), TypeScript treated the ref type as a constructor class instead of a component instance.
  2. Animate Method Signature (Add .animate() method to typings #328): The .animate() method signature was declared as returning Promise<void>, whereas createAnimatableComponent.js at runtime returns Promise<{ finished: boolean }>.

🛠️ What did we fix?

  • TypeScript Inheritance: Replaced extends Component, ClassicComponentClass<AnimatableProps<S> & P> with extends Component<AnimatableProps<S> & P, S> in typings/react-native-animatable.d.ts.
  • Animate Method Return Signature: Updated .animate(...) method signature to return Promise<{ finished: boolean }>.

🧪 Testing & Verification

  • Verified that component refs (e.g. useRef<Animatable.View>(null)) resolve cleanly to component instance types with access to instance methods (.slideInDown(), .animate(), etc.).
  • Verified alignment between typings/react-native-animatable.d.ts declarations and createAnimatableComponent.js runtime return values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect ref type Add .animate() method to typings

1 participant