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) <noreply@anthropic.com> 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) <noreply@anthropic.com> 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) <noreply@anthropic.com> 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) <noreply@anthropic.com> 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) <noreply@anthropic.com> 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 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.