From 307742eab73e2fd0f0d317b0c4ebde1fb61e554b Mon Sep 17 00:00:00 2001 From: Kaan Ozkan Date: Tue, 9 Jun 2026 15:54:00 -0400 Subject: [PATCH] Skip RBS type aliases as node signatures --- lib/spoom/rbs.rb | 3 +++ .../rbs_comments_to_sorbet_sigs_test.rb | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/spoom/rbs.rb b/lib/spoom/rbs.rb index acb7a512..b6543bed 100644 --- a/lib/spoom/rbs.rb +++ b/lib/spoom/rbs.rb @@ -105,6 +105,9 @@ def node_rbs_comments(node) location = location.join(continuation_comment.location) end continuation_comments.clear + + next if string.start_with?("type ") + res.signatures.prepend(Signature.new(string, location)) elsif string.start_with?("#|") continuation_comments << comment diff --git a/test/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs_test.rb b/test/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs_test.rb index 02e04064..3e7a59d7 100644 --- a/test/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs_test.rb +++ b/test/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs_test.rb @@ -629,6 +629,28 @@ def get_status ) end + def test_translate_type_alias_before_method_sig_with_translate_last_overloads_strategy + assert_rewrites_rbs( + from: <<~RUBY, + class Example + #: type status = Symbol + #: () -> status + def status; end + end + RUBY + + to_pretty_format_for_humans: <<~RUBY, + class Example + Status = T.type_alias { Symbol } + sig { returns(Status) } + def status; end + end + RUBY + + overloads_strategy: :translate_last, + ) + end + def test_translate_type_alias_with_generics assert_rewrites_rbs( from: <<~RUBY,