def fmt_type(data_type, inside_namespace=None):
if is_struct_type(data_type) and data_type.has_enumerated_subtypes():<EOL><INDENT>possible_types = []<EOL>possible_subtypes = data_type.get_all_subtypes_with_tags()<EOL>for _, subtype in possible_subtypes:<EOL><INDENT>possible_types.append(fmt_polymorphic_type_reference(subtype, inside_namespace))<EOL><DEDENT>if data_type.is_catch_all():<EOL><INDENT>possible_types.append(fmt_polymorphic_type_reference(data_type, inside_namespace))<EOL><DEDENT>return fmt_union(possible_types)<EOL><DEDENT>else:<EOL><INDENT>return fmt_type_name(data_type, inside_namespace)<EOL><DEDENT>
Returns a TypeScript type annotation for a data type.
May contain a union of enumerated subtypes.
inside_namespace should be set to the namespace that the type reference
occurs in, or None if this parameter is not relevant.