gem_rbs_collection icon indicating copy to clipboard operation
gem_rbs_collection copied to clipboard

`ActionView::Helpers::RenderingHelper#render` has incorrect block signature

Open clinejj opened this issue 4 years ago • 0 comments

When calling the #render method from a helper in a Rails app, for example:

module ApplicationHelper
  def render_partial(name, options)
    render(partial: name, **options)
  end
end

the current type definitions throw an error when validating in Steep due to an incorrect signature: rbs:

module ApplicationHelper : ActionView::Helpers
  def render_partial: (String name, Hash[Symbol, untyped] options) -> String
end

steep output:

[error] The method cannot be called without a block
│ Diagnostic ID: Ruby::RequiredBlockMissing
│
└     render(
      ~~~~~~

This specific one comes from ActionView::Helpers::RenderingHelper#render, which is defined on https://github.com/ruby/gem_rbs_collection/blob/main/gems/actionview/6.0/actionview-generated.rbs#L6603

      def render: (?::Hash[untyped, untyped] options, ?::Hash[untyped, untyped] locals) { () -> untyped } -> untyped

The patch to fix it is to make the block optional, ie ?{ () -> untyped }

I'm happy to make a PR to address, but not sure if you would prefer to update the generated files or the patch.

clinejj avatar Oct 06 '21 14:10 clinejj