Returns a JSDoc annotation for a data type.
    May contain a union of enumerated subtypes.
329590
def fmt_type(data_type):
    
    if is_struct_type(data_type) and data_type.has_enumerated_subtypes():
        possible_types = []
        possible_subtypes = data_type.get_all_subtypes_with_tags()
        for _, subtype in possible_subtypes:
            possible_types.append(fmt_type_name(subtype))
        if data_type.is_catch_all():
            possible_types.append(fmt_type_name(data_type))
        return fmt_jsdoc_union(possible_types)
    else:
        return fmt_type_name(data_type)
991326
function(hljs) {
  var ANNOTATION = {
    className: 'annotation', begin: '@[A-Za-z]+'
  };
  var STRING = {
    className: 'string',
    begin: 'u?r?"""', end: '"""',
    relevance: 10
  };
  var SYMBOL = {
    className: 'symbol',
    begin: '\'\\w[\\w\\d_]*(?!\')'
  };
  return {
    keywords:
      'type yield lazy override def with val var false true sealed abstract private trait ' +
      'object null if for while throw finally protected extends import final return else ' +
      'break new catch super class case package default try this match continue throws',
    contains: [
      {
        className: 'javadoc',
        begin: '/\\*\\*', end: '\\*/',
        contains: [{
          className: 'javadoctag',
          begin: '@[A-Za-z]+'
        }],
        relevance: 10
      },
      hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE,
      STRING, hljs.QUOTE_STRING_MODE,
      SYMBOL,
      {
        className: 'class',
        begin: '((case )?class |object |trait )', // beginKeywords won't work because a single "case" shouldn't start this mode
        end: '({|$)', excludeEnd: true,
        illegal: ':',
        keywords: 'case class trait object',
        contains: [
          {
            beginKeywords: 'extends with',
            relevance: 10
          },
          hljs.UNDERSCORE_TITLE_MODE,
          {
            className: 'params',
            begin: '\\(', end: '\\)',
            contains: [
              hljs.QUOTE_STRING_MODE, STRING,
              ANNOTATION
            ]
          }
        ]
      },
      hljs.C_NUMBER_MODE,
      ANNOTATION
    ]
  };
}
1210560
public static String getDataTypePattern(String datatypeKey)
    {
    	Datatype datatype = getDatatype(datatypeKey);
    	return datatype.getPattern();
    }
967686
def _jstype(self, stype, sval):
        
        if stype == self.IS_LIST:
            return "array"
        if stype == self.IS_DICT:
            return "object"
        if isinstance(sval, Scalar):
            return sval.jstype
        # it is a Schema, so return type of contents
        v = sval._schema
        return self._jstype(self._whatis(v), v)
751092
private Node parseTypeExpression(JsDocToken token) {
    // Save the source position before we consume additional tokens.
    int lineno = stream.getLineno();
    int charno = stream.getCharno();
    if (token == JsDocToken.QMARK) {
      // A QMARK could mean that a type is nullable, or that it's unknown.
      // We use look-ahead 1 to determine whether it's unknown. Otherwise,
      // we assume it means nullable. There are 8 cases:
      // {?} - right curly
      // ? - EOF (possible when the parseTypeString method is given a bare type expression)
      // {?=} - equals
      // {function(?, number)} - comma
      // {function(number, ?)} - right paren
      // {function(): ?|number} - pipe
      // {Array.<?>} - greater than
      // /** ? */ - EOC (inline types)
      // I'm not a big fan of using look-ahead for this, but it makes
      // the type language a lot nicer.
      token = next();
      if (token == JsDocToken.COMMA
          || token == JsDocToken.EQUALS
          || token == JsDocToken.RIGHT_SQUARE
          || token == JsDocToken.RIGHT_CURLY
          || token == JsDocToken.RIGHT_PAREN
          || token == JsDocToken.PIPE
          || token == JsDocToken.RIGHT_ANGLE
          || token == JsDocToken.EOC
          || token == JsDocToken.EOL
          || token == JsDocToken.EOF) {
        restoreLookAhead(token);
        return newNode(Token.QMARK);
      }

      return wrapNode(Token.QMARK, parseBasicTypeExpression(token), lineno, charno);
    } else if (token == JsDocToken.BANG) {
      return wrapNode(Token.BANG, parseBasicTypeExpression(next()), lineno, charno);
    } else {
      Node basicTypeExpr = parseBasicTypeExpression(token);
      lineno = stream.getLineno();
      charno = stream.getCharno();
      if (basicTypeExpr != null) {
        if (match(JsDocToken.QMARK)) {
          next();
          return wrapNode(Token.QMARK, basicTypeExpr, lineno, charno);
        } else if (match(JsDocToken.BANG)) {
          next();
          return wrapNode(Token.BANG, basicTypeExpr, lineno, charno);
        }
      }

      return basicTypeExpr;
    }
  }
405969
@DefinedBy(Api.LANGUAGE_MODEL)
    public <A extends Annotation> A[] getAnnotationsByType(Class<A> annoType) {

        if (!annoType.isAnnotation())
            throw new IllegalArgumentException("Not an annotation type: "
                                               + annoType);
        // If annoType does not declare a container this is equivalent to wrapping
        // getAnnotation(...) in an array.
        Class <? extends Annotation> containerType = getContainer(annoType);
        if (containerType == null) {
            A res = getAnnotation(annoType);
            int size = res == null ? 0 : 1;

            @SuppressWarnings("unchecked") // annoType is the Class for A
            A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);
            if (res != null)
                arr[0] = res;
            return arr;
        }

        // So we have a containing type
        String annoTypeName = annoType.getName();
        String containerTypeName = containerType.getName();
        int directIndex = -1, containerIndex = -1;
        Attribute.Compound direct = null, container = null;
        // Find directly (explicit or implicit) present annotations
        int index = -1;
        for (Attribute.Compound attribute : getAnnotationMirrors()) {
            index++;
            if (attribute.type.tsym.flatName().contentEquals(annoTypeName)) {
                directIndex = index;
                direct = attribute;
            } else if(containerTypeName != null &&
                      attribute.type.tsym.flatName().contentEquals(containerTypeName)) {
                containerIndex = index;
                container = attribute;
            }
        }

        // Deal with inherited annotations
        if (direct == null && container == null &&
                annoType.isAnnotationPresent(Inherited.class))
            return getInheritedAnnotations(annoType);

        Attribute.Compound[] contained = unpackContained(container);

        // In case of an empty legacy container we might need to look for
        // inherited annos as well
        if (direct == null && contained.length == 0 &&
                annoType.isAnnotationPresent(Inherited.class))
            return getInheritedAnnotations(annoType);

        int size = (direct == null ? 0 : 1) + contained.length;
        @SuppressWarnings("unchecked") // annoType is the Class for A
        A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);

        // if direct && container, which is first?
        int insert = -1;
        int length = arr.length;
        if (directIndex >= 0 && containerIndex >= 0) {
            if (directIndex < containerIndex) {
                arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
                insert = 1;
            } else {
                arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
                insert = 0;
                length--;
            }
        } else if (directIndex >= 0) {
            arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
            return arr;
        } else {
            // Only container
            insert = 0;
        }

        for (int i = 0; i + insert < length; i++)
            arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType);

        return arr;
    }
753404
function createAnnotation(desc) {
  utils.check(['type', 'hasTarget', 'annotatedBy'], desc);

  var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};

 // used to create a hierarchical position
 // FIXME reconcile roots / position
  var position = desc.roots || [], flattened = desc.type + unitSep;
  anno.roots = desc.roots || [];
  if (desc.type === 'quote') {
    utils.check(['ranges', 'quote'], desc);
    if (!desc.ranges || desc.ranges.length < 1) {
      utils.checkError(desc, 'missing ranges');
    }
    anno.quote = desc.quote;
    anno.ranges = desc.ranges;
    position.push(anno.quote);
    flattened += position.join(unitSep);
  } else if (desc.type === 'category') {
    utils.check(['category'], desc);
    anno.category = Array.isArray(desc.category) ? desc.category : [desc.category];
    position = position.concat(anno.category);
    flattened += position.join(unitSep);
  } else if (desc.type === 'value' || desc.type === 'valueQuote') {
    utils.check(['key', 'value'], desc);
    if (desc.type === 'valueQuote') {
      utils.check(['ranges'], desc);
      anno.ranges = desc.ranges;
    }
    anno.key = desc.key;
    anno.value = desc.value;
    position.push(desc.key);
    flattened += position.join(unitSep) + unitSep + desc.value;

// add data types
    if (desc.isA) {
      try {
        anno.isA = desc.isA;
        anno.typed = {};
        anno.typed[desc.isA] = dataTypes[desc.isA](desc.value);
      } catch (e) {
        anno.typed.failure = e;
        GLOBAL.warn('isA failed', e, desc);
      }
    }
  } else {
    throw new Error('unknown type ' + desc.type);
  }
  anno.position = position;
  anno.flattened = flattened;
  if (anno.attributes) {
    anno.attributes = desc.attributes; // additional attributes
  }
  return anno;
}
127025
public SparkDocumentStream annotate(@NonNull AnnotatableType... types) {
      return new SparkDocumentStream(source.map(json -> {
         Hermes.initializeWorker(configBroadcast.value());
         if (Document.hasAnnotations(json, types)) {
            return json;
         }
         Document document = Document.fromJson(json);
         Pipeline.process(document, types);
         return document.toJson();
      }));
   }
401871
private ImmutableSet<JSType> getTypesToSkipForType(JSType type) {
    type = type.restrictByNotNullOrUndefined();
    if (type.isUnionType()) {
      ImmutableSet.Builder<JSType> types = ImmutableSet.builder();
      types.add(type);
      for (JSType alt : type.getUnionMembers()) {
        types.addAll(getTypesToSkipForTypeNonUnion(alt));
      }
      return types.build();
    } else if (type.isEnumElementType()) {
      return getTypesToSkipForType(type.getEnumeratedTypeOfEnumElement());
    }
    return ImmutableSet.copyOf(getTypesToSkipForTypeNonUnion(type));
  }
313676
function createShapeChecker(shapeTypes) {

    return createChainableChecker(function (data, dataName, componentName, fullDataName) {

        if (getDataType(shapeTypes) !== 'object') {
            throw new Error('[SAN ERROR] '
                + 'Data `' + fullDataName + '` of `' + componentName + '` has invalid '
                + 'DataType notation inside `shape`, expected `object`'
            );
        }

        var dataValue = data[dataName];
        var dataType = getDataType(dataValue);

        if (dataType !== 'object') {
            throw new Error('[SAN ERROR] '
                + 'Invalid ' + componentName + ' data `' + fullDataName + '` of type'
                + '(' + dataType + ' supplied to ' + componentName + ', '
                + 'expected object)'
            );
        }

        for (var shapeKeyName in shapeTypes) {
            /* istanbul ignore else  */
            if (shapeTypes.hasOwnProperty(shapeKeyName)) {
                var checker = shapeTypes[shapeKeyName];
                if (typeof checker === 'function') {
                    checker(dataValue, shapeKeyName, componentName, fullDataName + '.' + shapeKeyName);
                }
            }
        }

    });

}
561239
function js2dtCLI (jsonFile, ramlTypeName) {
  const jsonData = fs.readFileSync(jsonFile).toString()

  if (ramlTypeName != null) {
    const raml = js2dt.js2dt(jsonData, ramlTypeName)
    return `#%RAML 1.0 Library\n${yaml.safeDump({ types: raml }, { 'noRefs': true })}`
  } else {
    const typeName = 'this__should__be__the__only__type'
    const raml = js2dt.js2dt(jsonData, typeName)

    const keys = Object.keys(raml)
    if (keys.length !== 1 || !keys.includes(typeName)) {
      throw new Error(`There is more than one type (${JSON.stringify(keys)}), please specify a name for the raml library`)
    }

    return `#%RAML 1.0 DataType\n${yaml.safeDump(raml[typeName], { 'noRefs': true })}`
  }
}
296444
def _generate_union_class_custom_annotations(self, ns, data_type):
        
        self.emit('def _process_custom_annotations(self, annotation_type, field_path, processor):')
        with self.indent(), emit_pass_if_nothing_emitted(self):
            self.emit(
                (
                    'super({}, self)._process_custom_annotations(annotation_type, field_path, '
                    'processor)'
                ).format(class_name_for_data_type(data_type))
            )
            self.emit()

            for field in data_type.fields:
                recursive_processors = list(self._generate_custom_annotation_processors(
                    ns, field.data_type, field.custom_annotations))

                # check if we have any annotations that apply to this field at all
                if len(recursive_processors) == 0:
                    continue

                field_name = fmt_func(field.name)
                self.emit('if self.is_{}():'.format(field_name))

                with self.indent():
                    for annotation_type, processor in recursive_processors:
                        annotation_class = class_name_for_annotation_type(annotation_type, ns)
                        self.emit('if annotation_type is {}:'.format(annotation_class))
                        with self.indent():
                            self.emit('self._value = {}'.format(
                                generate_func_call(
                                    processor,
                                    args=[
                                        "'{{}}.{}'.format(field_path)".format(field_name),
                                        'self._value',
                                    ])
                            ))
                        self.emit()
898675
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
            if (declaration.flags & 134217728 /* JavaScriptFile */) {
                // If this is a variable in a JavaScript file, then use the JSDoc type (if it has
                // one as its type), otherwise fallback to the below standard TS codepaths to
                // try to figure it out.
                var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration);
                if (type && type !== unknownType) {
                    return type;
                }
            }
            // A variable declared in a for..in statement is always of type string
            if (declaration.parent.parent.kind === 207 /* ForInStatement */) {
                return stringType;
            }
            if (declaration.parent.parent.kind === 208 /* ForOfStatement */) {
                // checkRightHandSideOfForOf will return undefined if the for-of expression type was
                // missing properties/signatures required to get its iteratedType (like
                // [Symbol.iterator] or next). This may be because we accessed properties from anyType,
                // or it may have led to an error inside getElementTypeOfIterable.
                return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType;
            }
            if (ts.isBindingPattern(declaration.parent)) {
                return getTypeForBindingElement(declaration);
            }
            // Use type from type annotation if one is present
            if (declaration.type) {
                return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality);
            }
            if (declaration.kind === 142 /* Parameter */) {
                var func = declaration.parent;
                // For a parameter of a set accessor, use the type of the get accessor if one is present
                if (func.kind === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) {
                    var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */);
                    if (getter) {
                        var getterSignature = getSignatureFromDeclaration(getter);
                        var thisParameter = getAccessorThisParameter(func);
                        if (thisParameter && declaration === thisParameter) {
                            // Use the type from the *getter*
                            ts.Debug.assert(!thisParameter.type);
                            return getTypeOfSymbol(getterSignature.thisParameter);
                        }
                        return getReturnTypeOfSignature(getterSignature);
                    }
                }
                // Use contextual parameter type if one is available
                var type = void 0;
                if (declaration.symbol.name === "this") {
                    var thisParameter = getContextualThisParameter(func);
                    type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined;
                }
                else {
                    type = getContextuallyTypedParameterType(declaration);
                }
                if (type) {
                    return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
                }
            }
            // Use the type of the initializer expression if one is present
            if (declaration.initializer) {
                return addOptionality(checkExpressionCached(declaration.initializer), /*optional*/ declaration.questionToken && includeOptionality);
            }
            // If it is a short-hand property assignment, use the type of the identifier
            if (declaration.kind === 254 /* ShorthandPropertyAssignment */) {
                return checkIdentifier(declaration.name);
            }
            // If the declaration specifies a binding pattern, use the type implied by the binding pattern
            if (ts.isBindingPattern(declaration.name)) {
                return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false, /*reportErrors*/ true);
            }
            // No type specified and nothing can be inferred
            return undefined;
        }
1309612
def get_custom_annotations_for_alias(data_type):
    
    # annotations can only be applied to Aliases, but they can be wrapped in
    # Nullable. also, Aliases pointing to other Aliases don't automatically
    # inherit their custom annotations, so we might have to traverse.
    result = []
    data_type, _ = unwrap_nullable(data_type)
    while is_alias(data_type):
        result.extend(data_type.custom_annotations)
        data_type, _ = unwrap_nullable(data_type.data_type)
    return result
179317
FunctionTypeBuilder inferParameterTypes(@Nullable Node paramsParent, @Nullable JSDocInfo info) {
    if (paramsParent == null) {
      if (info == null) {
        return this;
      } else {
        return inferParameterTypes(info);
      }
    }

    // arguments
    Node oldParameterType = null;
    if (parametersNode != null) {
      oldParameterType = parametersNode.getFirstChild();
    }

    FunctionParamBuilder builder = new FunctionParamBuilder(typeRegistry);
    boolean warnedAboutArgList = false;
    Set<String> allJsDocParams =
        (info == null) ? new HashSet<>() : new HashSet<>(info.getParameterNames());
    boolean isVarArgs = false;
    int paramIndex = 0;
    for (Node param : paramsParent.children()) {
      boolean isOptionalParam = false;

      if (param.isRest()) {
        isVarArgs = true;
        param = param.getOnlyChild();
      } else if (param.isDefaultValue()) {
        // The first child is the actual positional parameter
        param = checkNotNull(param.getFirstChild(), param);
        isOptionalParam = true;
      } else {
        isVarArgs = isVarArgsParameterByConvention(param);
        isOptionalParam = isOptionalParameterByConvention(param);
      }

      String paramName = null;
      if (param.isName()) {
        paramName = param.getString();
      } else {
        checkState(param.isDestructuringPattern());
        // Right now, the only way to match a JSDoc param to a destructuring parameter is through
        // ordering the JSDoc parameters. So the third formal parameter will correspond to the
        // third JSDoc parameter.
        if (info != null) {
          paramName = info.getParameterNameAt(paramIndex);
        }
      }
      allJsDocParams.remove(paramName);

      // type from JSDocInfo
      JSType parameterType = null;
      if (info != null && info.hasParameterType(paramName)) {
        JSTypeExpression parameterTypeExpression = info.getParameterType(paramName);
        parameterType = parameterTypeExpression.evaluate(templateScope, typeRegistry);
        isOptionalParam = isOptionalParam || parameterTypeExpression.isOptionalArg();
        isVarArgs = isVarArgs || parameterTypeExpression.isVarArgs();
      } else if (param.getJSDocInfo() != null && param.getJSDocInfo().hasType()) {
        JSTypeExpression parameterTypeExpression = param.getJSDocInfo().getType();
        parameterType = parameterTypeExpression.evaluate(templateScope, typeRegistry);
        isOptionalParam = parameterTypeExpression.isOptionalArg();
        isVarArgs = parameterTypeExpression.isVarArgs();
      } else if (oldParameterType != null &&
          oldParameterType.getJSType() != null) {
        parameterType = oldParameterType.getJSType();
        isOptionalParam = oldParameterType.isOptionalArg();
        isVarArgs = oldParameterType.isVarArgs();
      } else {
        parameterType = typeRegistry.getNativeType(UNKNOWN_TYPE);
      }

      warnedAboutArgList |= addParameter(
          builder, parameterType, warnedAboutArgList,
          isOptionalParam,
          isVarArgs);

      if (oldParameterType != null) {
        oldParameterType = oldParameterType.getNext();
      }
      paramIndex++;
    }
    // Copy over any old parameters that aren't in the param list.
    if (!isVarArgs) {
      while (oldParameterType != null && !isVarArgs) {
        builder.newParameterFromNode(oldParameterType);
        oldParameterType = oldParameterType.getNext();
      }
    }

    for (String inexistentName : allJsDocParams) {
      reportWarning(INEXISTENT_PARAM, inexistentName, formatFnName());
    }

    parametersNode = builder.build();
    return this;
  }
458929
function getResolvedJsxType(node, elemType, elemClassType) {
            if (!elemType) {
                elemType = checkExpression(node.tagName);
            }
            if (elemType.flags & 524288 /* Union */) {
                var types = elemType.types;
                return getUnionType(types.map(function (type) {
                    return getResolvedJsxType(node, type, elemClassType);
                }), /*subtypeReduction*/ true);
            }
            // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type
            if (elemType.flags & 2 /* String */) {
                return anyType;
            }
            else if (elemType.flags & 32 /* StringLiteral */) {
                // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type
                var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
                if (intrinsicElementsType !== unknownType) {
                    var stringLiteralTypeName = elemType.text;
                    var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
                    if (intrinsicProp) {
                        return getTypeOfSymbol(intrinsicProp);
                    }
                    var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */);
                    if (indexSignatureType) {
                        return indexSignatureType;
                    }
                    error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
                }
                // If we need to report an error, we already done so here. So just return any to prevent any more error downstream
                return anyType;
            }
            // Get the element instance type (the result of newing or invoking this tag)
            var elemInstanceType = getJsxElementInstanceType(node, elemType);
            if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) {
                // Is this is a stateless function component? See if its single signature's return type is
                // assignable to the JSX Element Type
                if (jsxElementType) {
                    var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */);
                    var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0];
                    var callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
                    var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
                    if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
                        // Intersect in JSX.IntrinsicAttributes if it exists
                        var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
                        if (intrinsicAttributes !== unknownType) {
                            paramType = intersectTypes(intrinsicAttributes, paramType);
                        }
                        return paramType;
                    }
                }
            }
            // Issue an error if this return type isn't assignable to JSX.ElementClass
            if (elemClassType) {
                checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
            }
            if (isTypeAny(elemInstanceType)) {
                return elemInstanceType;
            }
            var propsName = getJsxElementPropertiesName();
            if (propsName === undefined) {
                // There is no type ElementAttributesProperty, return 'any'
                return anyType;
            }
            else if (propsName === "") {
                // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead
                return elemInstanceType;
            }
            else {
                var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName);
                if (!attributesType) {
                    // There is no property named 'props' on this instance type
                    return emptyObjectType;
                }
                else if (isTypeAny(attributesType) || (attributesType === unknownType)) {
                    // Props is of type 'any' or unknown
                    return attributesType;
                }
                else if (attributesType.flags & 524288 /* Union */) {
                    // Props cannot be a union type
                    error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType));
                    return anyType;
                }
                else {
                    // Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
                    var apparentAttributesType = attributesType;
                    var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes);
                    if (intrinsicClassAttribs !== unknownType) {
                        var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
                        if (typeParams) {
                            if (typeParams.length === 1) {
                                apparentAttributesType = intersectTypes(createTypeReference(intrinsicClassAttribs, [elemInstanceType]), apparentAttributesType);
                            }
                        }
                        else {
                            apparentAttributesType = intersectTypes(attributesType, intrinsicClassAttribs);
                        }
                    }
                    var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes);
                    if (intrinsicAttribs !== unknownType) {
                        apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
                    }
                    return apparentAttributesType;
                }
            }
        }
755543
private void findProtoTypesRecurse(SoyType type, SortedSet<String> protoTypes) {
    switch (type.getKind()) {
      case PROTO:
        protoTypes.add(((SoyProtoType) type).getDescriptorExpression());
        break;

      case PROTO_ENUM:
        protoTypes.add(((SoyProtoEnumType) type).getDescriptorExpression());
        break;

      case UNION:
        for (SoyType member : ((UnionType) type).getMembers()) {
          findProtoTypesRecurse(member, protoTypes);
        }
        break;

      case LIST:
        {
          ListType listType = (ListType) type;
          findProtoTypesRecurse(listType.getElementType(), protoTypes);
          break;
        }

      case MAP:
      case LEGACY_OBJECT_MAP:
        {
          AbstractMapType mapType = (AbstractMapType) type;
          findProtoTypesRecurse(mapType.getKeyType(), protoTypes);
          findProtoTypesRecurse(mapType.getValueType(), protoTypes);
          break;
        }

      case RECORD:
        {
          RecordType recordType = (RecordType) type;
          for (SoyType fieldType : recordType.getMembers().values()) {
            findProtoTypesRecurse(fieldType, protoTypes);
          }
          break;
        }
      case VE:
        {
          VeType veType = (VeType) type;
          if (veType.getDataType().isPresent()) {
            // Don't grab the proto type for ve<null>
            SoyType soyType = typeRegistry.getType(veType.getDataType().get());
            if (soyType.getKind() == Kind.PROTO) {
              protoTypes.add(((SoyProtoType) soyType).getDescriptorExpression());
            }
          }
          break;
        }

      case ANY:
      case UNKNOWN:
      case ERROR:
      case NULL:
      case BOOL:
      case INT:
      case FLOAT:
      case STRING:
      case HTML:
      case ATTRIBUTES:
      case JS:
      case CSS:
      case URI:
      case TRUSTED_RESOURCE_URI:
      case VE_DATA:
        // continue
    }
  }