private void processReservedSymbols(TreeSet<String> provides,TypedScope topScope){
  Set<String> collapsedNamespaces=new TreeSet<>();
  for (  String reservedProvide : provides) {
    if (reservedJsWords.contains(getUnqualifiedName(reservedProvide))) {
      String namespace=getNamespace(reservedProvide);
      if (collapsedNamespaces.contains(namespace))       continue;
      collapsedNamespaces.add(namespace);
      Set<String> properties=getSubNamespace(provides,namespace);
      emitNamespaceBegin(getNamespace(namespace));
      emit("var");
      emit(getUnqualifiedName(namespace));
      emit(": {");
      Iterator<String> bundledIt=properties.iterator();
      while (bundledIt.hasNext()) {
        emit(getUnqualifiedName(bundledIt.next()));
        emit(":");
        TypedVar var=topScope.getOwnSlot(reservedProvide);
        if (var != null) {
          TreeWalker walker=new TreeWalker(compiler.getTypeRegistry(),provides,false);
          walker.visitType(var.getType());
        }
 else {
          emit("any");
        }
        if (bundledIt.hasNext())         emit(",");
      }
      emit("};");
      emitBreak();
      emitNamespaceEnd();
      for (      String property : properties) {
        declareModule(property,true,property,true);
      }
    }
  }
  Iterator<String> it=provides.iterator();
  while (it.hasNext()) {
    if (collapsedNamespaces.contains(getNamespace(it.next())))     it.remove();
  }
}

private void processReservedSymbols ( TreeSet < String > provides , TypedScope topScope ) { Set < String > collapsedNamespaces = new TreeSet < > ( ) ; for ( String reservedProvide : provides ) { if ( reservedJsWords . contains ( getUnqualifiedName ( reservedProvide ) ) ) { String namespace = getNamespace ( reservedProvide ) ; if ( collapsedNamespaces . contains ( namespace ) ) continue ; collapsedNamespaces . add ( namespace ) ; Set < String > properties = getSubNamespace ( provides , namespace ) ; emitNamespaceBegin ( getNamespace ( namespace ) ) ; emit ( "var" ) ; emit ( getUnqualifiedName ( namespace ) ) ; emit ( ": {" ) ; Iterator < String > bundledIt = properties . iterator ( ) ; while ( bundledIt . hasNext ( ) ) { emit ( getUnqualifiedName ( bundledIt . next ( ) ) ) ; emit ( ":" ) ; TypedVar var = topScope . getOwnSlot ( reservedProvide ) ; if ( var != null ) { TreeWalker walker = new TreeWalker ( compiler . getTypeRegistry ( ) , provides , false ) ; walker . visitType ( var . getType ( ) ) ; } else { emit ( "any" ) ; } if ( bundledIt . hasNext ( ) ) emit ( "," ) ; } emit ( "};" ) ; emitBreak ( ) ; emitNamespaceEnd ( ) ; for ( String property : properties ) { declareModule ( property , true , property , true ) ; } } } Iterator < String > it = provides . iterator ( ) ; while ( it . hasNext ( ) ) { if ( collapsedNamespaces . contains ( getNamespace ( it . next ( ) ) ) ) it . remove ( ) ; } }
reserved words are problematic because they cannot be used as var declarations , but are valid properties . for example : var switch = 0 ; / / parses badly in js . foo . switch = 0 ; / / ok . this means that closure code is allowed to goog . provide ( ' ng . components . switch ' ) , which cannot trivially translate in ts to : namespace ng . components { var switch : . . . ; } instead , go one step higher and generate : namespace ng { var components : { switch : . . . , } ; } this turns a namespace into a property of its parent namespace . note : this violates the invariant that generated namespaces are 1 - 1 with getnamespace of goog . provides .
