thatch-health / grape_sorbet

Sorbet signatures and Tapioca DSL compiler for Grape.
MIT License
4 stars 0 forks source link

Ignore anonymous helpers #4

Closed olivier-thatch closed 2 months ago

olivier-thatch commented 2 months ago

Ignore anonymous helpers instead of raising an exception.

The Tapioca compiler requires helper methods to be declared inside a named module rather than an anonymous helpers do ... end block in order to generate a proper RBI definition that Sorbet can use to know that the helper methods exist.

The initial version of the Tapioca compiler raised an exception when encountering anonymous helpers do ... end blocks to help enforce this. However this is at least one case in which the block form of helpers must be used: defining reusable params, e.g.:

  helpers do
    params :pagination do
      optional :page, type: Integer
      optional :per_page, type: Integer
    end
  end

This PR updates the compiler to simply skip over anonymous helpers blocks.