def _generate_union_type(self, union_type, indent_spaces):
<EOL>parent_type = union_type.parent_type<EOL>namespace = union_type.namespace<EOL>union_type_name = fmt_type_name(union_type, namespace)<EOL>variant_type_names = []<EOL>if parent_type:<EOL><INDENT>variant_type_names.append(fmt_type_name(parent_type, namespace))<EOL><DEDENT>def _is_struct_without_enumerated_subtypes(data_type):<EOL><INDENT>"""<STR_LIT>"""<EOL>return is_struct_type(data_type) and (<EOL>not data_type.has_enumerated_subtypes())<EOL><DEDENT>for variant in union_type.fields:<EOL><INDENT>if variant.doc:<EOL><INDENT>self._emit_tsdoc_header(variant.doc)<EOL><DEDENT>variant_name = '<STR_LIT>' % (union_type_name, fmt_pascal(variant.name))<EOL>variant_type_names.append(variant_name)<EOL>is_struct_without_enumerated_subtypes = _is_struct_without_enumerated_subtypes(<EOL>variant.data_type)<EOL>if is_struct_without_enumerated_subtypes:<EOL><INDENT>self.emit('<STR_LIT>' % (<EOL>variant_name, fmt_type(variant.data_type, namespace)))<EOL><DEDENT>else:<EOL><INDENT>self.emit('<STR_LIT>' % variant_name)<EOL><DEDENT>with self.indent(dent=indent_spaces):<EOL><INDENT>self.emit("<STR_LIT>" % variant.name)<EOL>if is_void_type(variant.data_type) is False and (<EOL>not is_struct_without_enumerated_subtypes<EOL>):<EOL><INDENT>self.emit("<STR_LIT>" % (variant.name, fmt_type(variant.data_type, namespace)))<EOL><DEDENT><DEDENT>self.emit('<STR_LIT:}>')<EOL>self.emit()<EOL><DEDENT>if union_type.doc:<EOL><INDENT>self._emit_tsdoc_header(union_type.doc)<EOL><DEDENT>self.emit('<STR_LIT>' % (union_type_name, '<STR_LIT>'.join(variant_type_names)))<EOL>self.emit()<EOL>
Generates a TypeScript interface for a stone union.