src/com/google/javascript/jscomp/TypeCheck.java
/** Visits an arrow function expression body. */
Visits an arrow function expression body.
Visits an arrow function expression body .
private void visitImplicitReturnExpression(NodeTraversal t, Node exprNode) {
    Node enclosingFunction = t.getEnclosingFunction();
    JSType jsType = getJSType(enclosingFunction);
    if (jsType.isFunctionType()) {
      FunctionType functionType = jsType.toMaybeFunctionType();
      JSType expectedReturnType = functionType.getReturnType();
      if (expectedReturnType == null) {
        expectedReturnType = getNativeType(VOID_TYPE);
      } else if (enclosingFunction.isAsyncFunction()) {
        expectedReturnType = Promises.getTemplateTypeOfThenable(typeRegistry, expectedReturnType);
      }
      JSType actualReturnType = getJSType(exprNode);
      if (enclosingFunction.isAsyncFunction()) {
        actualReturnType = Promises.getResolvedType(typeRegistry, actualReturnType);
      }
      validator.expectCanAssignTo(t, exprNode, actualReturnType, expectedReturnType,
          "inconsistent return type");
    }
  }
private void visitImplicitReturnExpression ( NodeTraversal t , Node exprNode ) { Node enclosingFunction = t . getEnclosingFunction ( ) ; JSType jsType = getJSType ( enclosingFunction ) ; if ( jsType . isFunctionType ( ) ) { FunctionType functionType = jsType . toMaybeFunctionType ( ) ; JSType expectedReturnType = functionType . getReturnType ( ) ; if ( expectedReturnType == null ) { expectedReturnType = getNativeType ( VOID_TYPE ) ; } else if ( enclosingFunction . isAsyncFunction ( ) ) { expectedReturnType = Promises . getTemplateTypeOfThenable ( typeRegistry , expectedReturnType ) ; } JSType actualReturnType = getJSType ( exprNode ) ; if ( enclosingFunction . isAsyncFunction ( ) ) { actualReturnType = Promises . getResolvedType ( typeRegistry , actualReturnType ) ; } validator . expectCanAssignTo ( t , exprNode , actualReturnType , expectedReturnType , "inconsistent return type" ) ; } }
Visits an arrow function expression body.
Visits an arrow function expression body .
// if no return type is specified, undefined must be returned // (it's a void function) // Unwrap the async function's declared return type. // Fetch the returned value's type