Fix incorrect TypeScript function types in index.d.ts #106
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.
Problem
The TypeScript definitions in
src/index.d.ts
had incorrect function types that provided no type safety or IntelliSense support. All callback functions were defined as(...args: unknown[]): unknown;
, which meant:For example,
onChange
was defined as:This provided no information about what argument the callback receives or what it should return.
Solution
Updated all function type definitions with proper TypeScript types based on the actual implementation:
onChange
Now properly typed to receive the new spinner value (number or null when emptied) and can return void, false to cancel the change, or a number to override the value.
Event Handlers (onFocus, onBlur, onKeyPress)
Now use proper React Native event types for TextInput focus, blur, and key press events.
Value Callbacks (onMin, onMax, onIncrease, onDecrease, onSubmit, onLongPress)
All value callbacks now properly typed to receive a single
number
parameter representing the relevant value.formatter
Now clearly shows it takes a number and must return a formatted string.
Benefits
✅ Type Safety: TypeScript now properly validates argument and return types at compile time
✅ IntelliSense: IDEs provide accurate autocomplete and parameter hints
✅ Self-Documenting: Function signatures clearly show expected types
✅ Error Prevention: Catches type mismatches before runtime
✅ No Breaking Changes: Existing JavaScript code continues to work without modifications
Example Usage
With these changes, developers now get full type checking and autocomplete:
Fixes the issue where TypeScript users had no type information for callback functions.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.