I'm migrating the way I generate RBI files from Sorbet to Tapioca. However, I am getting a recurring problem across a number of the RBI files for my Rails models. The RBI files seem to be tripping up when trying to produce a signature for a has_many relationship.
(Note - it's the RBI file itself rather than the model that is generating the warning)
In the user.rbi file, the signature for the user.plans has_many association is:
sig { returns(::ActiveRecord::Associations::CollectionProxy[Plan]) }
def plans; end
When I run srb tc I see the following error:
sorbet/rbi/dsl/user.rbi:110: Method [] does not exist on T.class_of(ActiveRecord::Associations::CollectionProxy) https://srb.help/7003
110 | sig { returns(::ActiveRecord::Associations::CollectionProxy[Plan]) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Got T.class_of(ActiveRecord::Associations::CollectionProxy) originating from:
sorbet/rbi/dsl/user.rbi:110:
110 | sig { returns(::ActiveRecord::Associations::CollectionProxy[Plan]) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you mean:
sorbet/rbi/gems/activerecord@6.1.4.1.rbi:3238: ActiveRecord::Delegation#[]
3238 | def [](*args, &block); end