I have a model with a jsonb column. This column accepts only json objects. Sorbet correctly generates the .rbi file containing the following:
module PushedContent::GeneratedAttributeMethods
sig { returns(T.nilable(T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[T.untyped, T.untyped], Integer, String))) }
def value; end
sig { params(value: T.nilable(T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[T.untyped, T.untyped], Integer, String))).void }
def value=(value); end
end
The jsonb column will always store arrays or hashes. Since these method signatures do not cover my needs, I decided to override them in my own file under the folder: sorbet/rbi/types/app/models/model.rbi
module PushedContent::GeneratedAttributeMethods
sig { returns(T.nilable(T::Array[T.untyped], T::Hash[T.untyped, T.untyped])) }
def value; end
sig { params(value: T.nilable(T::Array[T.untyped], T::Hash[T.untyped, T.untyped])).void }
def value=(value); end
end
when I run bundle exec rake rails_rbi:models\[Model\]
I was expecting that sorbet will see the overrided methods and it will exclude them from the auto generated file.
But unfortunately that is not the case. Methods exist in both files.
So I am getting type errors that correspond to the autogenerated files and not the ones I wrote.
Funny thing is that when I run srb tc
there are no errors.
When I remove the methods from the autogenerated file the type errors are gone, but obviously this is not the best way to handle it.
How can I override these methods so that they will be excluded from the autogenerated files?