Class: Rbs2ts::Converter::Types::Array

Inherits:
ConverterBase show all
Defined in:
lib/rbs2ts/converter/types.rb

Instance Method Summary collapse

Methods inherited from ConverterBase

#initialize

Constructor Details

This class inherits a constructor from Rbs2ts::Converter::Types::ConverterBase

Instance Method Details

#to_tsObject



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/rbs2ts/converter/types.rb', line 145

def to_ts
  array_type = type.args.first
  array_type_ts = Types::Resolver.to_ts(array_type)

  if array_type.is_a?(::RBS::Types::Union) ||
    array_type.is_a?(::RBS::Types::Intersection) ||
    array_type.is_a?(::RBS::Types::Optional)
    "(#{array_type_ts})[]"
  else
    "#{array_type_ts}[]"
  end

end