docs: 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;
          }