Separate RBS files to _internal directory to avoid exposing RBS #237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 use
rbs 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!