docs: add JSDoc and improve TypeScript definitions#414
Open
dashitongzhi wants to merge 1 commit into
Open
Conversation
- 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.
There was a problem hiding this comment.
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 on lines
13
to
15
| export function registerAnimation(animationName, animation) { | ||
| animationRegistry[animationName] = animation; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves the developer-facing surface of the library with documentation
and tighter TypeScript types.
index.js,registry.js,createAnimation.jsandcreateAnimatableComponent.jsso editors, type-checkers and generated docs (e.g. TypeDoc) describe parameters, return values and side effects.Functiontype foronAnimationBeginandonAnimationEndinreact-native-animatable.d.ts. The begin callback now correctly takes no arguments, the end callback receives anEndStateobject, andEndStateis exported for consumers.animate()method toPromise<EndState>(it was previouslyPromise<void>).registred→registeredin the error thrown bycreateAnimatableComponentwhen an unknown animation name is supplied.animate()(durationanditerationDelay) 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 thebegin/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 --statshows +173 / -5 lines across 6 files.