The aim of v2 is to be more intelligent with the codegen for thrift-server. In v1 a struct, union or exception defined in Thrift source becomes a class in the output TypeScript.
Something almost identical is generated for exceptions and unions.
There is weight and complexity to this that should be hidden from consumers. A struct in Thrift is more analogous to a TypeScript interface. A union is required to have one field and only one field. We have unions in TypeScript, but not with fields. We can can get compile-time guarantees around setting only one union field if we generate a TypeScript union of single-field interfaces. Exceptions do more naturally translate to classes. We can generate a class that extends Error and this would allow for more natural usage for consumers.
The aim of v2 is to be more intelligent with the codegen for thrift-server. In v1 a struct, union or exception defined in Thrift source becomes a class in the output TypeScript.
Becomes...
Something almost identical is generated for exceptions and unions.
There is weight and complexity to this that should be hidden from consumers. A struct in Thrift is more analogous to a TypeScript interface. A union is required to have one field and only one field. We have unions in TypeScript, but not with fields. We can can get compile-time guarantees around setting only one union field if we generate a TypeScript union of single-field interfaces. Exceptions do more naturally translate to classes. We can generate a class that extends Error and this would allow for more natural usage for consumers.