Open tk0miya opened 4 months ago
The types of enumerable methods (ex. #map, #to_a, and so on) of ActiveRecord::Associations::CollectionProxy are inferior.
#map
#to_a
ActiveRecord::Associations::CollectionProxy
For example, here is the type of #each and #map:
#each
$ bundle exec rbs -Isig method User::ActiveRecord_Associations_CollectionProxy each ::User::ActiveRecord_Associations_CollectionProxy#each defined_in: ::_ActiveRecord_Relation implementation: ::User::ActiveRecord_Associations_CollectionProxy accessibility: public types: () { (::User) -> void } -> self at /Users/tkomiya/path/to/project/.gem_rbs_collection/activerecord/7.1/activerecord.rbs:530:12...530:42
$ bundle exec rbs -Isig method User::ActiveRecord_Associations_CollectionProxy map ::User::ActiveRecord_Associations_CollectionProxy#map defined_in: ::Enumerable implementation: ::Enumerable accessibility: public types: [U] () { (untyped arg0) -> U } -> ::Array[U] at /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/core/enumerable.rbs:1554:11...1554:52 | () -> ::Enumerator[untyped, ::Array[untyped]] at /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/core/enumerable.rbs:1555:11...1555:53
The type of #each indicates it takes a block taking a User object as a block argument. On the other hand, #map takes a block taking an untyped object.
It's better to provide more precise types.
The types of enumerable methods (ex.
#map
,#to_a
, and so on) ofActiveRecord::Associations::CollectionProxy
are inferior.For example, here is the type of
#each
and#map
:The type of
#each
indicates it takes a block taking a User object as a block argument. On the other hand,#map
takes a block taking an untyped object.It's better to provide more precise types.