Source:
<code>private Void emitTemplatizedType(TemplatizedType type, boolean extendingInstanceClass, boolean inImplementsExtendsPosition) { ObjectType referencedType = type.getReferencedType(); String templateTypeName = extendingInstanceClass ? getAbsoluteName(type) + INSTANCE_CLASS_SUFFIX : getAbsoluteName(type); if (typeRegistry.getNativeType(ARRAY_TYPE).equals(referencedType) && type.getTemplateTypes().size() == 1) { if (inImplementsExtendsPosition) { emit("Array<"); } visitTypeAsPrimary(type.getTemplateTypes().get(0)); emit(inImplementsExtendsPosition ? ">" : "[]"); return null; } <START> if (!opts.allowPlatformExterns) { <END> switch (type.getDisplayName()) { case "Arguments": emit("IArguments"); return null; case "NodeList": emit("NodeList"); return null; case "MessageEvent": emit("MessageEvent"); return null; case "IThenable": templateTypeName = "PromiseLike"; break; case "IArrayLike": templateTypeName = "ArrayLike"; break; default: break; } } if (type.getTemplateTypes().isEmpty()) { emit(templateTypeName); typesUsed.add(type.getDisplayName()); return null; } Iterator<JSType> it = type.getTemplateTypes().iterator(); if (typeRegistry.getNativeType(OBJECT_TYPE).equals(referencedType)) { emit("{ ["); JSType keyType = it.next(); if (keyType.isNumberValueType()) { emit("n: number"); } else { if (!keyType.isStringValueType()) { emit(" "); } emit("s: string"); } emit("]:"); visitType(it.next()); emit("}"); return null; } emit(templateTypeName); typesUsed.add(type.getDisplayName()); emit("<"); while (it.hasNext()) { visitType(it.next()); if (it.hasNext()) { emit(","); } } emit(">"); return null; }</code><technical_language>+1 if need testing infra. a large output, if pass externs behavior is indistingushable, if do output externs. of a mock out externs a files instead of platform externs. If not, I ok a largish output for now</technical_language>

Target:
private Void emitTemplatizedType(TemplatizedType type, boolean extendingInstanceClass, boolean inImplementsExtendsPosition) { ObjectType referencedType = type.getReferencedType(); String templateTypeName = extendingInstanceClass ? getAbsoluteName(type) + INSTANCE_CLASS_SUFFIX : getAbsoluteName(type); if (typeRegistry.getNativeType(ARRAY_TYPE).equals(referencedType) && type.getTemplateTypes().size() == 1) { if (inImplementsExtendsPosition) { emit("Array<"); } visitTypeAsPrimary(type.getTemplateTypes().get(0)); emit(inImplementsExtendsPosition ? ">" : "[]"); return null; } if (!opts.emitPlatformExterns) { switch (type.getDisplayName()) { case "Arguments": emit("IArguments"); return null; case "NodeList": emit("NodeList"); return null; case "MessageEvent": emit("MessageEvent"); return null; case "IThenable": templateTypeName = "PromiseLike"; break; case "IArrayLike": templateTypeName = "ArrayLike"; break; default: break; } } if (type.getTemplateTypes().isEmpty()) { emit(templateTypeName); typesUsed.add(type.getDisplayName()); return null; } Iterator<JSType> it = type.getTemplateTypes().iterator(); if (typeRegistry.getNativeType(OBJECT_TYPE).equals(referencedType)) { emit("{ ["); JSType keyType = it.next(); if (keyType.isNumberValueType()) { emit("n: number"); } else { if (!keyType.isStringValueType()) { emit(" "); } emit("s: string"); } emit("]:"); visitType(it.next()); emit("}"); return null; } emit(templateTypeName); typesUsed.add(type.getDisplayName()); emit("<"); while (it.hasNext()) { visitType(it.next()); if (it.hasNext()) { emit(","); } } emit(">"); return null; }