chanzuckerberg / sorbet-rails

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

Generate sigs for scope, has_many, etc. #60

Open hdoan741 opened 5 years ago

hdoan741 commented 5 years ago

It is not possible to generate the sigs right now because T.proc support is limited right now. For example: It doesn't work with generic https://github.com/sorbet/sorbet/issues/1139 It doesn't work with variable inputs https://github.com/sorbet/sorbet/issues/1142 T.proc.bind doesn't work with T.nilable https://github.com/sorbet/sorbet/issues/498 T.proc.bind doesn't work with lambda https://github.com/sorbet/sorbet/issues/1143

Once support is improved, we can generate scope it like this

  sig { 
    params(
      name: Symbol, 
      body: T.proc.bind(District::Relation).returns(T.untyped), 
      block: T.nilable(T.proc.void),
    ).void
  }
  def scope(name, body, &block); end
dogweather commented 4 years ago

Is this why I get, e.g.,

Method `has_many` does not exist on `T.class_of(...)`(7003)

?