Repository navigation
Conversation
In Rails 6.0 through 8.1, Mapper::Resources#new yields through with_scope_level and path_scope, each of which returns the block's value. Replace the generated untyped signature with a generic one in actiondispatch.rbs, and test it in the 7.2 and 8.1 suites. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
gems/actionpack/README.md accepts changes only for Rails versions under maintenance, and 6.0 is not one, so restore its RBS. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
In Rails 7.2 and 8.1 the Mapper DSL methods either return the mapper (resource, resources, nested, namespace, scope, constraints, the HTTP verb helpers, mount, with_default_scope, and match/root in 7.2) or the value of their block (collection, member, shallow, controller, defaults), because they end in `self` or in `yield` through with_scope_level, path_scope and shallow_scope. The generated signatures returned untyped and required blocks on match (7.2) and concern, which also accepts a callable. In 8.1, Resources#match returns its path_or_actions array (it ends in `path_or_actions.each`), and root returns match's value, so both are typed as Array. Concerns#concerns likewise ends in `each`. Move these declarations out of actionpack-generated.rbs into actiondispatch.rbs, add the missing 7.2 HttpHelpers#options, and cover them in the 7.2 and 8.1 route-drawing tests. Sources: actionpack/lib/action_dispatch/routing/mapper.rb at v7.2.4 and v8.1.4. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
The previous commit dropped the Rails doc comments of the declarations it moved out of actionpack-generated.rbs and typed only return values. Move each doc comment onto its hand-written declaration, and type the arguments, options and blocks from mapper.rb at v7.2.4 and v8.1.4: - Type aliases and interfaces in Mapper name the option values that Mapping, Resource and Scope accept: paths, `via`, `format`, `only`/`except`, `to` endpoints (strings, Rack apps and lambdas, controller classes), constraints (hashes, `matches?` objects and request lambdas), and `on`. - `get`..`connect`, `match` and `mount` gain an overload for the `"path" => "controller#action"` and `App => "path"` hash forms, and drop the block Rails never calls. - `concern` gets overloads for a lambda, a callable object, or a block run on the mapper. - 8.1 also moves mount, options and connect out of the generated file. In 7.2 the verbs and match take several paths and match/root return the mapper; in 8.1 they take one path and match/root return the path array. The tests draw routes in the forms the Rails routing guide uses. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
concern with a block stores and returns the same mapper lambda shape as concern with a lambda, so type both overloads alike. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
apiology
marked this pull request as ready for review
October 19, 2026 18:31
|
@apiology Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
This was referenced Oct 20, 2026
apiology
added a commit
to iftheshoefritz/solargraph-rails
that referenced
this pull request
Oct 21, 2026
ruby/gem_rbs_collection#1106 may not merge soon, so on Rails 7.2 and later castwide/solargraph master still reports undefined for Mapper::Resources#new. Move its generic annotation out of rails_before_7_2 into the unscoped annotations, with a note to remove it once #1106 is released and the collection revision is bumped. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
apiology
added a commit
to iftheshoefritz/solargraph-rails
that referenced
this pull request
Oct 21, 2026
* Type routing Resources#new as the block value Mapper::Resources#new returns its block's value (path_scope yields it). The routes expectation of self came from the YARD gem mapper, which types every method named new as self; castwide/solargraph#1378 maps gems from source, so master reports undefined. ruby/gem_rbs_collection#1106 types it as [T] () { () -> T } -> T in the actionpack 7.2 and 8.1 RBS. Rails 7.0 and 7.1 resolve the 6.0 RBS, which that repo leaves unchanged, so add the same generic signature to the rails_before_7_2 annotations. Expect generic<T>. Released Solargraph 0.57.0 to 0.61.0 union it with the YARD self, so they are skipped. On master, Rails 7.2 and 8.0 need the collection revision bump that follows #1106 merging. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn * Annotate Resources#new for every Rails version ruby/gem_rbs_collection#1106 may not merge soon, so on Rails 7.2 and later castwide/solargraph master still reports undefined for Mapper::Resources#new. Move its generic annotation out of rails_before_7_2 into the unscoped annotations, with a note to remove it once #1106 is released and the collection revision is bumped. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn * Stop skipping Mapper#new on Solargraph 0.60 and 0.61 With the annotation applied for every Rails version, 0.60.4 and 0.61.0 infer generic<T> on Rails 7.2 and 8.0 too, and the spec fails on a skip that no longer holds. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Claude: This PR was written by Claude Code on behalf of @apiology.
Problem:
Route files type-check against
untyped, so routing mistakes pass:This covers the public
ActionDispatch::Routing::MapperDSL in 7.2 and 8.1.Solution: Declare the DSL in
actiondispatch.rbsfrommapper.rb(v7.2.4, v8.1.4), moving each generated declaration's Rails documentation with it:Mappername whatMapping,ResourceandScopeaccept: paths,via,format,only/except,to(strings, Rack apps, lambdas, controller classes), constraints (hashes,matches?objects, request lambdas) andon."path" => "controller#action"andApp => "path"hash forms, andconcernwith a lambda, callable or block. The verbs,matchandmountdrop the block, which Rails never calls.resources,scopeand the verbs; the block value forcollection,member,new,shallow,controlleranddefaults; in 8.1, the path array formatchandroot, which end inpath_or_actions.each.mountkeeps anuntypedapp, since engine classes respond tocallonly through railties. 6.0 is unchanged, pergems/actionpack/README.md.