Skip to content

Commit

Permalink
Merge pull request #1089 from gaborszakacs/typed-active-record-find
Browse files Browse the repository at this point in the history
Make ActiveRecord#find return value typed
  • Loading branch information
st0012 authored Aug 4, 2022
2 parents cfb03c6 + 77bcc69 commit 9e46b80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/active_record_relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def create_common_methods(common_relation_methods_module)
parameters: [
create_rest_param("args", type: "T.untyped"),
],
return_type: "T.untyped"
return_type: "T.any(#{constant_name}, T::Array[#{constant_name}])"
)
when :find_by
create_common_method(
Expand Down
2 changes: 1 addition & 1 deletion spec/tapioca/dsl/compilers/active_record_relations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def fifth; end
sig { returns(::Post) }
def fifth!; end
sig { params(args: T.untyped).returns(T.untyped) }
sig { params(args: T.untyped).returns(T.any(::Post, T::Array[::Post])) }
def find(*args); end
sig { params(args: T.untyped).returns(T.nilable(::Post)) }
Expand Down

0 comments on commit 9e46b80

Please sign in to comment.