Hi folks!
We started to get typechecking failures after this commit: 53bbc23 in #313
The code failing typecheck is a pretty standard Rails pattern:
data = params.require(:magic_links).permit(...)
data[:other_field] = other_value
@magic_link = organization.magic_links.create(data)
The typecheck error is:
app/controllers/controller.rb:90: Method valid? does not exist on T::Array[MagicLink] https://srb.help/7003
90 | if @magic_link.valid?
If we revert the change to actionpack.rbi, we get a clean typecheck:
$ bundle exec srb tc
No errors! Great job.
I think that the new signatures fight with the Rails interface where create can accept an array to create multiple records.
If I change the code to .create(*data), it passes typechecking (but .to_h doesn't, it still seems to think it is an array).
Happy to keep testing more on this, it's puzzling that this is the only method that is getting mixed up -- we use this pattern everywhere, it's such a common one.
Thanks!
Hi folks!
We started to get typechecking failures after this commit: 53bbc23 in #313
The code failing typecheck is a pretty standard Rails pattern:
The typecheck error is:
If we revert the change to actionpack.rbi, we get a clean typecheck:
I think that the new signatures fight with the Rails interface where
createcan accept an array to create multiple records.If I change the code to
.create(*data), it passes typechecking (but.to_hdoesn't, it still seems to think it is an array).Happy to keep testing more on this, it's puzzling that this is the only method that is getting mixed up -- we use this pattern everywhere, it's such a common one.
Thanks!