RBS Type Signatures
React on Rails includes RBS type signatures for improved type safety and IDE support.
Benefits
- Better autocomplete in supported IDEs
- Early detection of type errors during development
- Improved code documentation through types
- Enhanced refactoring safety with type-aware tools
IDE Support
RBS signatures work with:
- Steep - Static type checker for Ruby
- Solargraph - Ruby language server with RBS support
- RubyMine - Built-in RBS support
- VS Code - Via Ruby LSP extensions
Usage
Validation
To validate type signatures:
bundle exec rake rbs:validate
Or directly using the RBS CLI:
bundle exec rbs -I sig validate
Listing Type Files
To see all available RBS type signature files:
bundle exec rake rbs:list
Location
Type signatures are located in the sig/ directory, organized to mirror the lib/ directory structure:
sig/
├── react_on_rails.rbs # Main module and core classes
├── react_on_rails/
│ ├── configuration.rbs # Configuration class types
│ ├── helper.rbs # View helper method signatures
│ ├── server_rendering_pool.rbs # Server rendering types
│ ├── utils.rbs # Utility method signatures
│ └── ... # And more
For more details, see sig/README.md.
Contributing
When adding new public methods or classes to the gem, please also add corresponding RBS signatures. This helps maintain type safety and improves the development experience for all users.
Adding New Signatures
- Create or update the appropriate
.rbsfile in thesig/directory - Follow the existing structure and naming conventions
- Run
bundle exec rake rbs:validateto verify your changes - Include the RBS updates in your pull request
Compatibility
- Ruby >= 3.0 (RBS is included in Ruby 3.0+)
- RBS gem >= 2.0