from typing import List


def generate_class(class_type: str, name: str, types: List[str]) -> str:
    """Generate thrift struct from types
    >>> print(generate_class("struct", "Foo", ["i64", "optional string", "set<i32> (cpp.ref = 'true')"]))
    struct Foo {
      1: i64 field_1;
      2: optional string field_2;
      3: set<i32> (cpp.ref = 'true') field_3;
    }
    """
    lines = [f"{class_type} {name} {{"]
    for i, t in enumerate(types):
        lines.append("  {0}: {1} field_{0};".format(i + 1, t))
    lines.append(f'}} (any_type.name="facebook.com/thrift/test/testset/{name}")')
    return "\n".join(lines)