Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activestorage.rbi #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
"active_record"
]
},
"activestorage": {
"dependencies": [
"rails"
],
"requires": [
"rails",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it fail without rails dependency and require?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not. Active Storage doesn't depend on Rails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ActiveStorage::Blob/ActiveStorage::Attachment are technically models, it needs to load the ActiveStorage engine, and the engine failed to load until rails was added as a dependency. Is there a smaller dependency I can use to get the engine to work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem seems to be there is a require "rails" dependency in ActiveStorage, but it's not declared as a dependency in the gemspec. Same goes for Action Cable, Action Mailbox and Action Text.

Comment on lines +28 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous comment was not correct, this work locally without upstream changes:

Suggested change
"dependencies": [
"rails"
],
"requires": [
"rails",
"dependencies": [
"railties"
],
"requires": [

Rails contains a single file and dependencies on all gems (including Railties), Railties has what we actually need.

"active_storage/engine",
"active_storage"
]
},
"activesupport": {
"requires": [
"active_support",
Expand Down
19 changes: 19 additions & 0 deletions rbi/annotations/activestorage.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# typed: strict

class ActiveStorage::Attached::One
# @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Analyzable
# @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Identifiable
# @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Representable
end

class ActiveStorage::Attached::Many
# @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Analyzable
# @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Identifiable
# @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing`
include ActiveStorage::Blob::Representable
end