function createFunctionReturnGuard (path: NodePath, context: VisitorContext): void {
    const {node, scope} = path;
    let annotation = node.returnType;
    if (annotation.type === 'TypeAnnotation') {
      annotation = annotation.typeAnnotation;
    }
    if (isGeneratorAnnotation(annotation)) {
      annotation = annotation.typeParameters && annotation.typeParameters.params.length > 1 ? annotation.typeParameters.params[1] : t.anyTypeAnnotation();
    }
    else if (node.async && annotation.type === 'GenericTypeAnnotation' && annotation.id.name === 'Promise') {
      annotation = (annotation.typeParameters && annotation.typeParameters[0]) || t.anyTypeAnnotation();
    }
    const name = scope.generateUidIdentifierBasedOnNode(node);
    const id = scope.generateUidIdentifier('id');
    const check = checkAnnotation(id, annotation, scope);
    if (check) {
      node.returnGuard = guardFn({
        id,
        name,
        check,
        message: returnTypeErrorMessage(path, path.node, id, context)
      });
      node.returnGuard.hasBeenTypeChecked = true;
      node.returnGuardName = name;
      node.returnGuardCount = 0;
    }
  }
Create a function which can verify the return type for a function.