Class: Rbs2ts::Converter::Types::Tuple

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



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rbs2ts/converter/types.rb', line 69

def to_ts
  tuple_types_ts = type.types.map {|t|
    ts = Types::Resolver.to_ts(t)

    if t.is_a?(::RBS::Types::Union) ||
      t.is_a?(::RBS::Types::Intersection) ||
      t.is_a?(::RBS::Types::Optional)
      "(#{ts})"
    else
      ts
    end
  }.join(', ')

  "[#{tuple_types_ts}]"
end