chanzuckerberg / sorbet-rails

A set of tools to make the Sorbet typechecker work with Ruby on Rails seamlessly.
MIT License
638 stars 84 forks source link

Method object does not exist on ActionView::Helpers::FormBuilder #434

Closed jcoyne closed 3 years ago

jcoyne commented 3 years ago

Describe the bug:

$ srb tc
app/components/collections/update/participant_row_component.rb:20: Method object does not exist on ActionView::Helpers::FormBuilder https://srb.help/7003
    20 |        form.object
                ^^^^^^^^^^^
  Got ActionView::Helpers::FormBuilder originating from:
    app/components/collections/update/participant_row_component.rb:20:
    20 |        form.object
                ^^^^
  Autocorrect: Use `-a` to autocorrect
    app/components/collections/update/participant_row_component.rb:20: Replace with object_id
    20 |        form.object
                     ^^^^^^
Errors: 1

This is surprising considering it appears to be defined here: https://github.com/chanzuckerberg/sorbet-rails/blob/1e9e8d0bc8e17b77f4a4f828814bb006c2bd96f3/sorbet/rbi/gems/actionview.rbi#L390

Steps to reproduce:

Reference the object method on an instance of ActionView::Helpers::FormBuilder

Expected behavior:

The object method is found

Versions:

jcoyne commented 3 years ago

Nevermind, I see that is the sorbet stubs that this gem uses.

I was able to workaround by adding a file to my app (sorbet/rbi/custom/action_view.rbi) with the following.

# typed: strong

class ActionView::Helpers::FormBuilder
  sig { returns(T.untyped) }
  def object; end
end