Source:
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.allowPlatformExterns) { 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; }

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