def _generate_union(self, union_type):
        """
        Emits a JSDoc @typedef for a union type.
        """
        union_name = fmt_type_name(union_type)
        self._emit_jsdoc_header(union_type.doc)
        self.emit(' * @typedef {Object} %s' % union_name)
        variant_types = []
        for variant in union_type.all_fields:
            variant_types.append("'%s'" % variant.name)
            variant_data_type, _, _ = unwrap(variant.data_type)
            # Don't emit fields for void types.
            if not is_void_type(variant_data_type):
                variant_doc = ' - Available if .tag is %s.' % variant.name
                if variant.doc:
                    variant_doc += ' ' + variant.doc
                self.emit_wrapped_text(
                    '@property {%s} [%s]%s' % (
                        fmt_type(variant_data_type),
                        variant.name,
                        variant_doc,
                    ),
                    prefix=' * ',
                )
        jsdoc_tag_union = fmt_jsdoc_union(variant_types)
        self.emit(' * @property {%s} .tag - Tag identifying the union variant.' % jsdoc_tag_union)
        self.emit(' */')
Emits a JSDoc @typedef for a union type.