code: private void validateTypeAnnotations(Node n, JSDocInfo info) {
      if (info != null && info.hasType()) {
        boolean valid = false;
        switch (n.getToken()) {
          // Function declarations are valid
          case FUNCTION:
            valid = NodeUtil.isFunctionDeclaration(n);
            break;
          // Object literal properties, catch declarations and variable
          // initializers are valid.
          case NAME:
            valid = isTypeAnnotationAllowedForName(n);
            break;
          case ARRAY_PATTERN:
          case OBJECT_PATTERN:
            // allow JSDoc like
            //   function f(/** !Object */ {x}) {}
            //   function f(/** !Array */ [x]) {}
            valid = n.getParent().isParamList();
            break;
          // Casts, exports, and Object literal properties are valid.
          case CAST:
          case EXPORT:
          case STRING_KEY:
          case GETTER_DEF:
          case SETTER_DEF:
            valid = true;
            break;
          // Declarations are valid iff they only contain simple names
          //   /** @type {number} */ var x = 3; // ok
          //   /** @type {number} */ var {x} = obj; // forbidden
          case VAR:
          case LET:
          case CONST:
            valid = !NodeUtil.isDestructuringDeclaration(n);
            break;
          // Property assignments are valid, if at the root of an expression.
          case ASSIGN: {
            Node lvalue = n.getFirstChild();
            valid = n.getParent().isExprResult()
                && (lvalue.isGetProp()
                    || lvalue.isGetElem()
                    || lvalue.matchesQualifiedName("exports"));
            break;
          }
          case GETPROP:
            valid = n.getParent().isExprResult() && n.isQualifiedName();
            break;
          case CALL:
            valid = info.isDefine();
            break;
          default:
            break;
        }
  
        if (!valid) {
          reportMisplaced(n, "type", "Type annotations are not allowed here. "
              + "Are you missing parentheses?");
        }
      }
    }
docs: Check that JSDoc with a {@code @type} annotation is in a valid place.