function resolveTypeAnnotation(node) {
    let annotation = (node.left && node.left.typeAnnotation) || node.typeAnnotation || node;
    while (annotation && (annotation.type === 'TypeAnnotation' || annotation.type === 'NullableTypeAnnotation')) {
      annotation = annotation.typeAnnotation;
    }
    if (annotation.type === 'GenericTypeAnnotation' && getInTypeScope(annotation.id.name)) {
      return getInTypeScope(annotation.id.name);
    }
    return annotation;
  }
Resolve the type annotation for a given node.
Flow annotations are sometimes wrapped in outer `TypeAnnotation`
and `NullableTypeAnnotation` nodes which obscure the annotation we're
interested in.
This method also resolves type aliases where possible.

@param {ASTNode} node The annotation or a node containing the type annotation.
@returns {ASTNode} The resolved type annotation for the node.