fix: string union type

This commit is contained in:
Kevin Franklin Kim 2024-11-08 14:22:22 +01:00
parent d3f19585b2
commit 6a79ac8f38
No known key found for this signature in database
9 changed files with 12 additions and 14 deletions

View File

@ -1,6 +1,7 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
// github.com/foomo/gotsrpc/v2/example/basic/service.Float32Type
export enum Float32Type {
Float32AType = 1,

View File

@ -1,8 +1,10 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_errors_service_frontend from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMulti
export type ErrMulti = (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA) & (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB)
export const ErrMulti = { ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA, ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB }
export type ErrMulti = typeof ErrMulti
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMultiA
export enum ErrMultiA {
One = "one",

View File

@ -1,6 +1,7 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomType
export enum ACustomType {
One = "one",

View File

@ -1,7 +1,6 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-client.ts to ./client/src/service-vo-service.ts
import * as time from './service-vo-time'; // ./client/src/service-client.ts to ./client/src/service-vo-time.ts
export class ServiceClient {
public static defaultEndpoint = "/service";

View File

@ -1,7 +1,6 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-service.ts
import * as time from './service-vo-time'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-time.ts
// github.com/foomo/gotsrpc/v2/example/time/service.TimeStruct
export interface TimeStruct {
time:number;

View File

@ -1,7 +1,7 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-service.ts
import * as time from './service-vo-time'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-time.ts
// time.Time
export interface Time {
}

View File

@ -47,4 +47,4 @@ function assertExhaustive(
message: string = 'msg'
): never {
throw new Error(message);
}
}

View File

@ -1,6 +1,7 @@
/* eslint:disable */
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
import * as github_com_foomo_gotsrpc_v2_example_union_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
// github.com/foomo/gotsrpc/v2/example/union/service.InlineStruct
export interface InlineStruct extends github_com_foomo_gotsrpc_v2_example_union_service.InlineStructA , github_com_foomo_gotsrpc_v2_example_union_service.InlineStructB {
value:string;
@ -19,7 +20,8 @@ export interface InlineStructPtr extends Partial<github_com_foomo_gotsrpc_v2_exa
value:string;
}
// github.com/foomo/gotsrpc/v2/example/union/service.UnionString
export type UnionString = (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA) & (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB)
export const UnionString = { ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA, ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB }
export type UnionString = typeof UnionString
// github.com/foomo/gotsrpc/v2/example/union/service.UnionStringA
export enum UnionStringA {
One = "one",

View File

@ -185,13 +185,7 @@ func renderTypescriptStruct(str *Struct, mappings config.TypeScriptMappings, sca
}
ts.app(" }")
ts.nl()
ts.app("export type " + str.Name + " = ")
for i, field := range str.UnionFields {
if i > 0 {
ts.app(" | ")
}
field.Value.tsType(mappings, scalars, structs, ts, &JSONInfo{OmitEmpty: true})
}
ts.app("export type " + str.Name + " = typeof " + str.Name)
ts.nl()
default:
return errors.New("could not resolve this union type")