|
| 1 | +# RBS Type Signatures |
| 2 | + |
| 3 | +React on Rails includes [RBS](https://github.com/ruby/rbs) type signatures for improved type safety and IDE support. |
| 4 | + |
| 5 | +## Benefits |
| 6 | + |
| 7 | +- **Better autocomplete** in supported IDEs |
| 8 | +- **Early detection of type errors** during development |
| 9 | +- **Improved code documentation** through types |
| 10 | +- **Enhanced refactoring safety** with type-aware tools |
| 11 | + |
| 12 | +## IDE Support |
| 13 | + |
| 14 | +RBS signatures work with: |
| 15 | + |
| 16 | +- [Steep](https://github.com/soutaro/steep) - Static type checker for Ruby |
| 17 | +- [Solargraph](https://solargraph.org/) - Ruby language server with RBS support |
| 18 | +- RubyMine - Built-in RBS support |
| 19 | +- VS Code - Via Ruby LSP extensions |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +### Validation |
| 24 | + |
| 25 | +To validate type signatures: |
| 26 | + |
| 27 | +```bash |
| 28 | +bundle exec rake rbs:validate |
| 29 | +``` |
| 30 | + |
| 31 | +Or directly using the RBS CLI: |
| 32 | + |
| 33 | +```bash |
| 34 | +bundle exec rbs -I sig validate |
| 35 | +``` |
| 36 | + |
| 37 | +### Listing Type Files |
| 38 | + |
| 39 | +To see all available RBS type signature files: |
| 40 | + |
| 41 | +```bash |
| 42 | +bundle exec rake rbs:list |
| 43 | +``` |
| 44 | + |
| 45 | +## Location |
| 46 | + |
| 47 | +Type signatures are located in the `sig/` directory, organized to mirror the `lib/` directory structure: |
| 48 | + |
| 49 | +``` |
| 50 | +sig/ |
| 51 | +├── react_on_rails.rbs # Main module and core classes |
| 52 | +├── react_on_rails/ |
| 53 | +│ ├── configuration.rbs # Configuration class types |
| 54 | +│ ├── helper.rbs # View helper method signatures |
| 55 | +│ ├── server_rendering_pool.rbs # Server rendering types |
| 56 | +│ ├── utils.rbs # Utility method signatures |
| 57 | +│ └── ... # And more |
| 58 | +``` |
| 59 | + |
| 60 | +For more details, see [sig/README.md](../../sig/README.md). |
| 61 | + |
| 62 | +## Contributing |
| 63 | + |
| 64 | +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. |
| 65 | + |
| 66 | +### Adding New Signatures |
| 67 | + |
| 68 | +1. Create or update the appropriate `.rbs` file in the `sig/` directory |
| 69 | +2. Follow the existing structure and naming conventions |
| 70 | +3. Run `bundle exec rake rbs:validate` to verify your changes |
| 71 | +4. Include the RBS updates in your pull request |
| 72 | + |
| 73 | +## Compatibility |
| 74 | + |
| 75 | +- Ruby >= 3.0 (RBS is included in Ruby 3.0+) |
| 76 | +- RBS gem >= 2.0 |
| 77 | + |
| 78 | +## Resources |
| 79 | + |
| 80 | +- [RBS Documentation](https://github.com/ruby/rbs) |
| 81 | +- [RBS Syntax Guide](https://github.com/ruby/rbs/blob/master/docs/syntax.md) |
| 82 | +- [Steep Type Checker](https://github.com/soutaro/steep) |
| 83 | +- [Solargraph Language Server](https://solargraph.org/) |
0 commit comments