Closed pocke closed 2 years ago
Thank you for the detailed investigation!
I don't think the type signature for ::Object#presence
is right.
class ::Object
def presence: () -> String?
end
The definition of presence
is:
class Object
def presence
self if present?
end
end
So, presence
returns the receiver or nil, not String or nil.
Note: I'm very new to RBS, so I might be wrong here. I just looked at this PR, because Dependabot told me about meta-tags 2.17.0.
Thanks @natematykiewicz
No problem!
This PR moves RBS declarations to
_internal
directory to avoid exposing internal RBS.Problem
The method definitions for
Hash
andObject
in the RBSs are duplicated with ActiveSupport's RBS. For example: https://github.com/ruby/gem_rbs_collection/blob/6320a194c85afbf4ff332c3eb75fcae2a6518c92/gems/activesupport/6.0/activesupport-generated.rbs#L3298RBS doesn't allow duplicated method definitions, so we cannot use meta-tags gem and ActiveSupport RBS at the same time. For example:
Solution
Move the conflicted RBSs to
_internal
directory.RBS ignores directories that start with
_
if the directory is loaded as a library. So when you want to make a polyfill, you can use_internal
directory. It is loaded when we develop meta-tags gem itself, but it is not loaded when we use meta-tags gem from other application/library.I also moved the interfaces under
MetaTags
namespace. The interfaces are necessary for exposed RBSs, so I didn't move them to_internal
directory. They are defined at the top level, so I moved them under the namespace to avoid conflicting other RBS.Alternative Solution
We can also use the ActiveSupport's RBS from ruby/gem_rbs_collection repository instead of the polyfill. But I didn't recommend this way for now.
Because currently Steep supports
rbs collection
feature partially.rbs collection
is the library management system for RBS, like Bundler. You can install dependencies' RBSs with the command out of the box. RBS v1 provides it as an experimental feature and it's GA on RBS v2. The latest Steep is not compatible with RBS v2. So to userbs collection
, we need to use the experimental one, lack of some features, or use the master branch of Steep.I think it is premature to use stably, so I recommend using the polyfill.
A lot of thanks to writing RBSs!