Skip to content

v1.0.4 - TypeScript Improvements & Better Developer Experience

Choose a tag to compare

@boranfurkan boranfurkan released this 03 Dec 18:18
· 4 commits to main since this release

Release v1.0.4 - TypeScript Improvements & Better Developer Experience

🎯 What's New

This release focuses on improving TypeScript support, fixing autocomplete issues, and enhancing overall developer experience.

✨ Improvements

πŸ”§ TypeScript & Autocomplete

  • Fixed type prop autocomplete - Now properly suggests all 9 button variants (primary, secondary, tertiary, success, error, warning, info, anchor, danger) in your IDE
  • Added size prop autocomplete - Get suggestions for 'small', 'medium', 'large' while still allowing custom string values
  • Improved type safety - Replaced all any types with proper TypeScript types throughout the codebase

πŸ›‘οΈ Type Safety Enhancements

  • helpers.ts improvements
    • Added proper Record<string, string> types for CSS modules
    • Made POSITION_STATES a const assertion for better type inference
    • Added explicit return types to all functions
    • Improved null safety checks
  • Button3D.tsx improvements
    • Changed element prop from complex ForwardRefExoticComponent to simpler React.ElementType
    • Added strict type for setCssEndEvent parameter: 'transition' | 'animation'
    • Better type definitions for cssModule prop

πŸ› Bug Fixes

  • Fixed memory leak in setCssEndEvent helper function
    • Added proper cleanup of event listeners
    • Implemented resolved flag to prevent double resolution
    • Ensures timeout is cleared when promise resolves early

πŸ“¦ Package Optimization

  • Added .npmignore - Extra safeguard to exclude unnecessary files from npm package
  • Better exports - Added named export alongside default export for Button3D
    // Both import styles now work
    import Button3D from 'react-3d-button'
    import { Button3D } from 'react-3d-button'

🎨 Developer Experience

  • Better IDE support - IntelliSense now shows all available props with proper types
  • Improved error messages - TypeScript will catch more issues at compile time
  • Consistent type annotations - More maintainable codebase

πŸ“Š Impact

  • βœ… No breaking changes - Fully backward compatible
  • βœ… Better autocomplete - IntelliSense works perfectly for type and size props
  • βœ… Type safety - Eliminated all any types for better compile-time checks
  • βœ… Memory safety - No more potential event listener leaks
  • βœ… Smaller package - Optimized with .npmignore

πŸ”„ Migration Guide

No migration needed! This release is 100% backward compatible. Just update:

npm update react-3d-button
# or
yarn upgrade react-3d-button
# or
pnpm update react-3d-button

πŸ“ Full Changelog

Changed

  • Improved type prop definition - removed generic string to enable autocomplete
  • Enhanced size prop with predefined values ('small' | 'medium' | 'large')
  • Upgraded all helper functions with proper TypeScript types
  • Simplified element prop type for better compatibility

Fixed

  • Memory leak in setCssEndEvent with proper cleanup
  • Event listener accumulation in long-running applications
  • Null/undefined edge cases in helper functions

Added

  • .npmignore file for package size optimization
  • Named export for Button3D component
  • React type imports in helpers.ts
  • Comprehensive type annotations throughout

πŸ™ Credits

Thanks to everyone using react-3d-button! These improvements were driven by community feedback and usage patterns.

πŸ“¦ Install

npm install react-3d-button@1.0.4

πŸ”— Links