def _generate_struct_type(self, struct_type, indent_spaces, extra_parameters):
namespace = struct_type.namespace<EOL>if struct_type.doc:<EOL><INDENT>self._emit_tsdoc_header(struct_type.doc)<EOL><DEDENT>parent_type = struct_type.parent_type<EOL>extends_line = '<STR_LIT>' % fmt_type_name(parent_type, namespace) if parent_type else '<STR_LIT>'<EOL>self.emit('<STR_LIT>' % (fmt_type_name(struct_type, namespace), extends_line))<EOL>with self.indent(dent=indent_spaces):<EOL><INDENT>for param_name, param_type, param_docstring in extra_parameters:<EOL><INDENT>if param_docstring:<EOL><INDENT>self._emit_tsdoc_header(param_docstring)<EOL><DEDENT>self.emit('<STR_LIT>' % (param_name, param_type))<EOL><DEDENT>for field in struct_type.fields:<EOL><INDENT>doc = field.doc<EOL>field_type, nullable = unwrap_nullable(field.data_type)<EOL>field_ts_type = fmt_type(field_type, namespace)<EOL>optional = nullable or field.has_default<EOL>if field.has_default:<EOL><INDENT>doc = doc + '<STR_LIT>' if doc else '<STR_LIT>'<EOL>doc = "<STR_LIT>" % field.default<EOL><DEDENT>if doc:<EOL><INDENT>self._emit_tsdoc_header(doc)<EOL><DEDENT>field_name = '<STR_LIT>' % field.name if optional else field.name<EOL>self.emit('<STR_LIT>' % (field_name, field_ts_type))<EOL><DEDENT><DEDENT>self.emit('<STR_LIT:}>')<EOL>self.emit()<EOL>if struct_type.is_member_of_enumerated_subtypes_tree():<EOL><INDENT>if struct_type.has_enumerated_subtypes():<EOL><INDENT>tag_values = []<EOL>for tags, _ in struct_type.get_all_subtypes_with_tags():<EOL><INDENT>for tag in tags:<EOL><INDENT>tag_values.append('<STR_LIT>' % tag)<EOL><DEDENT><DEDENT>tag_union = fmt_union(tag_values)<EOL>self._emit_tsdoc_header('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % fmt_type_name(struct_type, namespace))<EOL>self.emit('<STR_LIT>' %<EOL>(fmt_polymorphic_type_reference(struct_type, namespace),<EOL>fmt_type_name(struct_type, namespace)))<EOL>with self.indent(dent=indent_spaces):<EOL><INDENT>self._emit_tsdoc_header('<STR_LIT>')<EOL>self.emit('<STR_LIT>' % tag_union)<EOL><DEDENT>self.emit('<STR_LIT:}>')<EOL>self.emit()<EOL><DEDENT>else:<EOL><INDENT>parent = struct_type.parent_type<EOL>while not parent.has_enumerated_subtypes():<EOL><INDENT>parent = parent.parent_type<EOL><DEDENT>for subtype in parent.get_enumerated_subtypes():<EOL><INDENT>if subtype.data_type == struct_type:<EOL><INDENT>self._emit_tsdoc_header('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>fmt_type_name(struct_type, namespace))<EOL>self.emit('<STR_LIT>' %<EOL>(fmt_polymorphic_type_reference(struct_type, namespace),<EOL>fmt_type_name(struct_type, namespace)))<EOL>with self.indent(dent=indent_spaces):<EOL><INDENT>self._emit_tsdoc_header('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.emit_wrapped_text('<STR_LIT>' % subtype.name)<EOL><DEDENT>self.emit('<STR_LIT:}>')<EOL>self.emit()<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Generates a TypeScript interface for a stone struct.