Skip to content

Commit

Permalink
Do not print type parameters as TYPE_ when translating to RBS
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
  • Loading branch information
Morriar committed Jan 14, 2025
1 parent e9c6406 commit c239e18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rbi/rbs_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def visit_method(node)
sig { params(node: RBI::Method, sig: Sig).void }
def print_method_sig(node, sig)
unless sig.type_params.empty?
print("[#{sig.type_params.map { |t| "TYPE_#{t}" }.join(", ")}] ")
print("[#{sig.type_params.join(", ")}] ")
end

block_param = node.params.find { |param| param.is_a?(BlockParam) }
Expand Down Expand Up @@ -955,7 +955,7 @@ def visit_proc(type)

sig { params(type: Type::TypeParameter).void }
def visit_type_parameter(type)
@string << "TYPE_#{type.name}"
@string << type.name.to_s
end

sig { params(type: Type::Class).void }
Expand Down
2 changes: 1 addition & 1 deletion test/rbi/rbs_printer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def foo(a); end

# To avoid conflict with existing constants, we prefix type parameters with `TYPE_`
assert_equal(<<~RBI, rbi.rbs_string)
def foo: [TYPE_U, TYPE_V] (TYPE_U a) -> TYPE_V
def foo: [U, V] (U a) -> V
RBI
end

Expand Down

0 comments on commit c239e18

Please sign in to comment.