Skip to content

Commit 92d492f

Browse files
authored
Merge pull request #186 from apiology/undefined_type
Support Solargraph's 'undefined' type
2 parents e15833a + f2acdf8 commit 92d492f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/sord/type_converter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def self.yard_to_parlour(yard, item, config)
131131
Parlour::Types::Untyped.new
132132
when "bool", "Bool", "boolean", "Boolean", "true", "false"
133133
Parlour::Types::Boolean.new
134+
when "undefined" # solargraph convention
135+
Parlour::Types::Untyped.new
134136
when 'self'
135137
Parlour::Types::Self.new
136138
when Array

spec/type_converter_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def yard_to_parlour_default(type)
5858
end
5959
end
6060

61+
context 'with undefined' do
62+
it 'translates to untyped' do
63+
expect(yard_to_parlour_default('undefined')).to eq Types::Untyped.new
64+
end
65+
end
66+
6167
context 'with multiple types' do
6268
it 'unwraps it if it contains one item' do
6369
expect(yard_to_parlour_default(['String'])).to eq Types::Raw.new('String')
@@ -339,7 +345,7 @@ def self.path
339345
Sord::TypeConverter::Configuration.new(
340346
output_language: :rbs,
341347
replace_errors_with_untyped: false,
342-
replace_unresolved_with_untyped: false,
348+
replace_unresolved_with_untyped: false,
343349
)
344350
end
345351

0 commit comments

Comments
 (0)