RBS is a language to describe the structure of Ruby programs. You can write down the definition of a class or module: methods defined in the class, instance variables and their types, and inheritance/mix-in relations. It also allows declaring constants and global variables.
Questions tagged [rbs]
12 questions
9
votes
2 answers
Ruby 3 RBS type checking
Don't understand how to write and setup ruby 3 RBS type checking.
Let's say I have a similar file:
### file name: my_project/book.rb
class Book
def initialize(pages)
@pages = pages
end
def pages
@pages
end
end
first_book =…

Daishiro
- 133
- 2
- 8
5
votes
1 answer
How to configure Steep to find RBS files for a gem outside the stdlib?
Cannot find type `Sinatra::Base`
ruby file
class StaticApp < Sinatra::Base
end
rbs file
class StaticApp < Sinatra::Base
end
run
bundle exec steep check --log-level=fatal
result
[error] Cannot find type `Sinatra::Base`
Diagnostic ID:…

gayavat
- 18,910
- 11
- 45
- 55
2
votes
0 answers
use class inside a gemfile on rbs files
I am working in .rbs files in ruby and I and everything were working inside my app until I decided to declare the Redis type in the .rbs file.
I am using the gemfile redis
and then I have this function:
def redis_connect
Redis.new(host:…

TiGreX
- 1,602
- 3
- 26
- 41
2
votes
1 answer
What is the correct RBS signature for **options
What is the correct RBS description for the following Ruby method:
def insert( id:, **options )
# ...
'Hello World'
end
Assuming the following usage:
insert( id: 123, a: 'A', b: 'B' )

Itay Grudev
- 7,055
- 4
- 54
- 86
1
vote
2 answers
Ruby RBS: Declaring schema for a hash
In the application my team and I are working on, we heavily utilize Ruby hashes as data transfer objects(DTOs). Also, currently, we would like to try the combination of RBS and Steep to see if it will bring any noticeable benefit to the development…

TK-95
- 1,141
- 2
- 10
- 21
1
vote
1 answer
Ruby types and singleton methods
I'm seeing some unexpected behaviour setting up RBS types on an existing Ruby project. A minimal example:
# lib/a.rb
class A
def self.foo
new
end
end
class B < A
def self.foo
super
end
end
puts A.foo.inspect
puts…

jjg
- 907
- 8
- 18
1
vote
0 answers
Better way to enable RBS type checking in Rspec tests?
I'm incrementally adding RBS type signatures to my Ruby (not Rails) project. The project contains a Rakefile for running tests manually, but also a Guardfile for running tests when files change.
For that reason I've added the RBS setup to…

Duncan Bayne
- 3,870
- 4
- 39
- 64
1
vote
0 answers
Autogenerate/sync Typescript Types and Ruby Types
Ruby has types through RBS or Sorbet. What's the best way to autogenerate/sync Typescript Types with Ruby Types?
The pain point that I am trying to solve is avoiding bugs caused by misalignments between Front-End (Typescript) and Back-End (Ruby)…

Aga
- 11
- 1
1
vote
1 answer
steep check returns RBS::UnknownTypeName on DateTime
I am implementing a .rbs file for the ruby code and everything works but the DateTime. This is what I have:
ruby file:
class foo
# other attributes
attr_reader :bar
def initialize(bar)
@bar = bar
end
end
this is the rbs file:
class…

TiGreX
- 1,602
- 3
- 26
- 41
1
vote
2 answers
RubyMine dont support rbs
I want to try RBS in RubyMine,so I follow this link: https://www.jetbrains.com/help/ruby/rbs.html
but in my RubyMine,rbs not work
rbs not work
in video there's new rbs file but no in my RubyMine
no menu
my RubyMine version: 2021.3.2
ruby…

varlxj
- 11
- 1
1
vote
0 answers
Ruby RBS - how to include classes in the rbs/stdlib, e.g. BigDecimal?
I'm experimenting with some of the RBS type check in Ruby 3. I can't seem to use the classes inside the rbs/stdlib (https://github.com/ruby/rbs/tree/master/stdlib) such as BigDecimal.
This sample test:
# file lib/user.rb
require 'bigdecimal'
class…

Linh
- 535
- 1
- 6
- 13
0
votes
0 answers
How to keep an RBS signature up to date when code changes
How to keep an RBS signature up to date when code changes
Starting with some code I generate an RBS signature. I then make some changes to the code. How do I update the RBS signature to reflect the changes without having to start from…

Michael Lee Squires
- 81
- 5