Skip to content

docs: add JSDoc and improve TypeScript definitions#414

Open
dashitongzhi wants to merge 1 commit into
oblador:masterfrom
dashitongzhi:feat/docs-and-types-20260604090522
Open

docs: add JSDoc and improve TypeScript definitions#414
dashitongzhi wants to merge 1 commit into
oblador:masterfrom
dashitongzhi:feat/docs-and-types-20260604090522

Conversation

@dashitongzhi

Copy link
Copy Markdown

Summary

Improves the developer-facing surface of the library with documentation
and tighter TypeScript types.

  • Add JSDoc blocks to every exported function in index.js, registry.js, createAnimation.js and createAnimatableComponent.js so editors, type-checkers and generated docs (e.g. TypeDoc) describe parameters, return values and side effects.
  • Fix the loose Function type for onAnimationBegin and onAnimationEnd in react-native-animatable.d.ts. The begin callback now correctly takes no arguments, the end callback receives an EndState object, and EndState is exported for consumers.
  • Correct the return type of the imperative animate() method to Promise<EndState> (it was previously Promise<void>).
  • Fix typo registredregistered in the error thrown by createAnimatableComponent when an unknown animation name is supplied.
  • Document the second and third arguments of animate() (duration and iterationDelay) in the README and add a chained-loop example.

Why

The TypeScript definitions shipped with the package advertise the wrong
return type for animate(), the wrong signatures for the
begin/end animation callbacks, and contain no JSDoc to describe exported
helpers. None of the changes alter runtime behaviour — they only make
the public API easier to consume from TypeScript and from JSDoc-aware
tooling.

Test plan

  • git diff --stat shows +173 / -5 lines across 6 files.
  • No source files were renamed or deleted.
  • No runtime logic was changed (the typo fix is purely cosmetic).

- Add JSDoc blocks to all exported functions in index.js, registry.js,
  createAnimation.js and createAnimatableComponent.js so editors and
  generated API docs describe parameters, return values and side effects.
- Replace generic 'Function' type with proper signatures in
  react-native-animatable.d.ts: onAnimationEnd now receives EndState,
  onAnimationBegin takes no arguments, EndState is exported, and the
  return type of animate() is corrected to Promise<EndState>.
- Fix typo 'registred' -> 'registered' in the
  createAnimatableComponent error message.
- Document the second and third arguments of animate() in the README
  (duration, iterationDelay) with a chained-loop example.
Copilot AI review requested due to automatic review settings June 4, 2026 01:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves developer-facing documentation and TypeScript typings for react-native-animatable, including clearer public API docs and more precise callback/promise shapes.

Changes:

  • Added/expanded JSDoc comments across the public entry points and helpers.
  • Enhanced TypeScript declarations (e.g., EndState, better callback types, richer prop docs).
  • Updated README to document extra animate() parameters and fixed a typo in an error message.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
typings/react-native-animatable.d.ts Adds richer TS types/docs (e.g., EndState, callback signatures, method return shapes).
registry.js Adds JSDoc for registry APIs (register/get/list/initialize).
index.js Documents the module entry point and exported precomposed components.
createAnimation.js Documents compilation + caching behavior for custom animations.
createAnimatableComponent.js Fixes error-message typo and documents HOC factory behavior.
README.md Documents optional animate() arguments with an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread registry.js
Comment on lines 13 to 15
export function registerAnimation(animationName, animation) {
animationRegistry[animationName] = animation;
}
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.

2 participants