From 6a532b2684e60c0d55c3388b69cc08ed201c8f49 Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Sun, 31 May 2020 21:31:40 -0400 Subject: [PATCH 1/2] Change client to return instances of our classes. This changes the client code generated for `--target thrift-server` so that it returns instances of the generated thrift classes instead of plain objects. I believe the client code generated for `--target apache` already behaves this way. One advantage is this allows `instanceof` to be used on Thrift responses, which makes exceptions [distinguishable from each other](https://github.com/creditkarma/thrift-typescript/issues/181) using `instanceof`. It would also increase the usefulness of having [exception classes derive from Error](https://github.com/creditkarma/thrift-typescript/issues/178). The change itself is small and easy. The compiler already generates "MyEndpoint__Result" classes that have a read() function that instantiates the class, I just needed to call it from the appropriate place in the Client class. To review this change it'll be helpful if you're familiar with the various classes that are generated. I'll refrain from trying to describe it here--you're better off looking some generated code on your own. Here's a diff showing how this change affects a generated ping function. This is in the Client class: ``` public ping(context?: Context): Promise { const writer: thrift.TTransport = new this.transport(); const output: thrift.TProtocol = new this.protocol(writer); output.writeMessageBegin("ping", thrift.MessageType.CALL, this.incrementRequestId()); const args: IPing__ArgsArgs = {}; Ping__ArgsCodec.encode(args, output); output.writeMessageEnd(); return this.connection.send(writer.flush(), context).then((data: Buffer) => { const reader: thrift.TTransport = this.transport.receiver(data); const input: thrift.TProtocol = new this.protocol(reader); try { const { fieldName: fieldName, messageType: messageType }: thrift.IThriftMessage = input.readMessageBegin(); if (fieldName === "ping") { if (messageType === thrift.MessageType.EXCEPTION) { const err: thrift.TApplicationException = thrift.TApplicationExceptionCodec.decode(input); input.readMessageEnd(); return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); } else { return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, "ping failed: unknown result")); } } } else { return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.WRONG_METHOD_NAME, "Received a response to an unknown RPC function: " + fieldName)); } } catch (err) { return Promise.reject(err); } }); } ``` You'll notice that I also changed the type of `result` from `IPing__Result` to `Ping__Result`. This isn't important and could be reverted, but I think it's better this way. I like keeping types specific until the point where it's useful for them to be generic. I'd advocate for making the same change to the types of struct class members (would need to change these types, I think: https://github.com/creditkarma/thrift-typescript/blob/e8931ff0d98c871360af99bbfa805cfd088d2f0e/src/main/render/thrift-server/struct/class.ts#L293 and https://github.com/creditkarma/thrift-typescript/blob/e8931ff0d98c871360af99bbfa805cfd088d2f0e/src/main/render/thrift-server/struct/reader.ts#L51), though that isn't of immediately use to me personally and I don't intend to pursue it. Remaining work: - Fix tests. --- src/main/render/thrift-server/service/client.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/render/thrift-server/service/client.ts b/src/main/render/thrift-server/service/client.ts index 11b46524..1fb3dbe1 100644 --- a/src/main/render/thrift-server/service/client.ts +++ b/src/main/render/thrift-server/service/client.ts @@ -51,7 +51,7 @@ import { import { Resolver } from '../../../resolver' import { createBufferType, createPromiseType } from '../../shared/types' import { createClassConstructor } from '../../shared/utils' -import { looseName, strictName, toolkitName } from '../struct/utils' +import { className, looseName, toolkitName } from '../struct/utils' function extendsAbstract(): ts.HeritageClause { return ts.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ @@ -515,7 +515,7 @@ function createConnectionSend(): ts.CallExpression { ) } -// const result: GetUserResult = GetUserResultCodec.decode(input); +// const result: GetUser__Result = GetUser__Result.read(input); function createNewResultInstance( def: FunctionDefinition, state: IRenderState, @@ -525,16 +525,16 @@ function createNewResultInstance( COMMON_IDENTIFIERS.result, ts.createTypeReferenceNode( ts.createIdentifier( - strictName(createStructResultName(def), def.type, state), + className(createStructResultName(def), state), ), undefined, ), ts.createCall( ts.createPropertyAccess( ts.createIdentifier( - toolkitName(createStructResultName(def), state), + className(createStructResultName(def), state), ), - COMMON_IDENTIFIERS.decode, + COMMON_IDENTIFIERS.read, ), undefined, [COMMON_IDENTIFIERS.input], From e11e26b461941017a3d612c837fefb5301da62e1 Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Fri, 28 Aug 2020 18:13:20 -0400 Subject: [PATCH 2/2] Fix tests. --- .../annotations_service.solution.ts | 6 ++-- .../thrift-server/basic_service.solution.ts | 6 ++-- .../basic_service.strict_union.solution.ts | 4 +-- .../generated-strict/SharedService.ts | 4 +-- .../generated-strict/SharedServiceBase.ts | 2 +- .../com/test/calculator/Calculator.ts | 30 +++++++++---------- .../thrift-server/generated/SharedService.ts | 4 +-- .../generated/SharedServiceBase.ts | 2 +- .../com/test/calculator/Calculator.ts | 30 +++++++++---------- .../thrift-server/i64_service.solution.ts | 4 +-- .../resolved_field_service.solution.ts | 2 +- .../throws_multi_service.solution.ts | 2 +- .../thrift-server/throws_service.solution.ts | 4 +-- 13 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/tests/unit/fixtures/thrift-server/annotations_service.solution.ts b/src/tests/unit/fixtures/thrift-server/annotations_service.solution.ts index 27c928d6..c3c7f415 100644 --- a/src/tests/unit/fixtures/thrift-server/annotations_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/annotations_service.solution.ts @@ -622,7 +622,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IGetUser__Result = GetUser__ResultCodec.decode(input); + const result: GetUser__Result = GetUser__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -660,7 +660,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: ISaveUser__Result = SaveUser__ResultCodec.decode(input); + const result: SaveUser__Result = SaveUser__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } @@ -693,7 +693,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/basic_service.solution.ts b/src/tests/unit/fixtures/thrift-server/basic_service.solution.ts index 24b8d6a8..ed58f1e9 100644 --- a/src/tests/unit/fixtures/thrift-server/basic_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/basic_service.solution.ts @@ -610,7 +610,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IGetUser__Result = GetUser__ResultCodec.decode(input); + const result: GetUser__Result = GetUser__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -648,7 +648,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: ISaveUser__Result = SaveUser__ResultCodec.decode(input); + const result: SaveUser__Result = SaveUser__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } @@ -681,7 +681,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/basic_service.strict_union.solution.ts b/src/tests/unit/fixtures/thrift-server/basic_service.strict_union.solution.ts index 724abd64..046bd497 100644 --- a/src/tests/unit/fixtures/thrift-server/basic_service.strict_union.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/basic_service.strict_union.solution.ts @@ -493,7 +493,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IGetUser__Result = GetUser__ResultCodec.decode(input); + const result: GetUser__Result = GetUser__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -531,7 +531,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/generated-strict/SharedService.ts b/src/tests/unit/fixtures/thrift-server/generated-strict/SharedService.ts index cf35aca7..ed31e968 100644 --- a/src/tests/unit/fixtures/thrift-server/generated-strict/SharedService.ts +++ b/src/tests/unit/fixtures/thrift-server/generated-strict/SharedService.ts @@ -359,7 +359,7 @@ export class Client extends SharedServiceBase.Client { return Promise.reject(err); } else { - const result: IGetUnion__Result = GetUnion__ResultCodec.decode(input); + const result: GetUnion__Result = GetUnion__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -397,7 +397,7 @@ export class Client extends SharedServiceBase.Client { return Promise.reject(err); } else { - const result: IGetEnum__Result = GetEnum__ResultCodec.decode(input); + const result: GetEnum__Result = GetEnum__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); diff --git a/src/tests/unit/fixtures/thrift-server/generated-strict/SharedServiceBase.ts b/src/tests/unit/fixtures/thrift-server/generated-strict/SharedServiceBase.ts index d08fa011..a0fc45dd 100644 --- a/src/tests/unit/fixtures/thrift-server/generated-strict/SharedServiceBase.ts +++ b/src/tests/unit/fixtures/thrift-server/generated-strict/SharedServiceBase.ts @@ -216,7 +216,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IGetStruct__Result = GetStruct__ResultCodec.decode(input); + const result: GetStruct__Result = GetStruct__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); diff --git a/src/tests/unit/fixtures/thrift-server/generated-strict/com/test/calculator/Calculator.ts b/src/tests/unit/fixtures/thrift-server/generated-strict/com/test/calculator/Calculator.ts index 1addbc57..866ea63b 100644 --- a/src/tests/unit/fixtures/thrift-server/generated-strict/com/test/calculator/Calculator.ts +++ b/src/tests/unit/fixtures/thrift-server/generated-strict/com/test/calculator/Calculator.ts @@ -2758,7 +2758,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } @@ -2791,7 +2791,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAdd__Result = Add__ResultCodec.decode(input); + const result: Add__Result = Add__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); @@ -2832,7 +2832,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAddInt64__Result = AddInt64__ResultCodec.decode(input); + const result: AddInt64__Result = AddInt64__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); @@ -2873,7 +2873,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAddWithContext__Result = AddWithContext__ResultCodec.decode(input); + const result: AddWithContext__Result = AddWithContext__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -2911,7 +2911,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICalculate__Result = Calculate__ResultCodec.decode(input); + const result: Calculate__Result = Calculate__Result.read(input); input.readMessageEnd(); if (result.ouch != null) { return Promise.reject(result.ouch); @@ -2952,7 +2952,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IEchoBinary__Result = EchoBinary__ResultCodec.decode(input); + const result: EchoBinary__Result = EchoBinary__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -2990,7 +2990,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IEchoString__Result = EchoString__ResultCodec.decode(input); + const result: EchoString__Result = EchoString__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3028,7 +3028,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICheckName__Result = CheckName__ResultCodec.decode(input); + const result: CheckName__Result = CheckName__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3066,7 +3066,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICheckOptional__Result = CheckOptional__ResultCodec.decode(input); + const result: CheckOptional__Result = CheckOptional__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3104,7 +3104,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IMapOneList__Result = MapOneList__ResultCodec.decode(input); + const result: MapOneList__Result = MapOneList__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3142,7 +3142,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IMapValues__Result = MapValues__ResultCodec.decode(input); + const result: MapValues__Result = MapValues__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3180,7 +3180,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IListToMap__Result = ListToMap__ResultCodec.decode(input); + const result: ListToMap__Result = ListToMap__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3218,7 +3218,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IFetchThing__Result = FetchThing__ResultCodec.decode(input); + const result: FetchThing__Result = FetchThing__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3256,7 +3256,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IFetchMap__Result = FetchMap__ResultCodec.decode(input); + const result: FetchMap__Result = FetchMap__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3294,7 +3294,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IZip__Result = Zip__ResultCodec.decode(input); + const result: Zip__Result = Zip__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/generated/SharedService.ts b/src/tests/unit/fixtures/thrift-server/generated/SharedService.ts index 6eff0d8e..37976fa5 100644 --- a/src/tests/unit/fixtures/thrift-server/generated/SharedService.ts +++ b/src/tests/unit/fixtures/thrift-server/generated/SharedService.ts @@ -359,7 +359,7 @@ export class Client extends SharedServiceBase.Client { return Promise.reject(err); } else { - const result: IGetUnion__Result = GetUnion__ResultCodec.decode(input); + const result: GetUnion__Result = GetUnion__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -397,7 +397,7 @@ export class Client extends SharedServiceBase.Client { return Promise.reject(err); } else { - const result: IGetEnum__Result = GetEnum__ResultCodec.decode(input); + const result: GetEnum__Result = GetEnum__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); diff --git a/src/tests/unit/fixtures/thrift-server/generated/SharedServiceBase.ts b/src/tests/unit/fixtures/thrift-server/generated/SharedServiceBase.ts index d08fa011..a0fc45dd 100644 --- a/src/tests/unit/fixtures/thrift-server/generated/SharedServiceBase.ts +++ b/src/tests/unit/fixtures/thrift-server/generated/SharedServiceBase.ts @@ -216,7 +216,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IGetStruct__Result = GetStruct__ResultCodec.decode(input); + const result: GetStruct__Result = GetStruct__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); diff --git a/src/tests/unit/fixtures/thrift-server/generated/com/test/calculator/Calculator.ts b/src/tests/unit/fixtures/thrift-server/generated/com/test/calculator/Calculator.ts index 138828e7..f802c6d3 100644 --- a/src/tests/unit/fixtures/thrift-server/generated/com/test/calculator/Calculator.ts +++ b/src/tests/unit/fixtures/thrift-server/generated/com/test/calculator/Calculator.ts @@ -2758,7 +2758,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } @@ -2791,7 +2791,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAdd__Result = Add__ResultCodec.decode(input); + const result: Add__Result = Add__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); @@ -2832,7 +2832,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAddInt64__Result = AddInt64__ResultCodec.decode(input); + const result: AddInt64__Result = AddInt64__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); @@ -2873,7 +2873,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IAddWithContext__Result = AddWithContext__ResultCodec.decode(input); + const result: AddWithContext__Result = AddWithContext__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -2911,7 +2911,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICalculate__Result = Calculate__ResultCodec.decode(input); + const result: Calculate__Result = Calculate__Result.read(input); input.readMessageEnd(); if (result.ouch != null) { return Promise.reject(result.ouch); @@ -2952,7 +2952,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IEchoBinary__Result = EchoBinary__ResultCodec.decode(input); + const result: EchoBinary__Result = EchoBinary__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -2990,7 +2990,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IEchoString__Result = EchoString__ResultCodec.decode(input); + const result: EchoString__Result = EchoString__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3028,7 +3028,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICheckName__Result = CheckName__ResultCodec.decode(input); + const result: CheckName__Result = CheckName__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3066,7 +3066,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: ICheckOptional__Result = CheckOptional__ResultCodec.decode(input); + const result: CheckOptional__Result = CheckOptional__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3104,7 +3104,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IMapOneList__Result = MapOneList__ResultCodec.decode(input); + const result: MapOneList__Result = MapOneList__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3142,7 +3142,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IMapValues__Result = MapValues__ResultCodec.decode(input); + const result: MapValues__Result = MapValues__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3180,7 +3180,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IListToMap__Result = ListToMap__ResultCodec.decode(input); + const result: ListToMap__Result = ListToMap__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3218,7 +3218,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IFetchThing__Result = FetchThing__ResultCodec.decode(input); + const result: FetchThing__Result = FetchThing__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3256,7 +3256,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IFetchMap__Result = FetchMap__ResultCodec.decode(input); + const result: FetchMap__Result = FetchMap__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -3294,7 +3294,7 @@ export class Client extends __ROOT_NAMESPACE__.SharedService.Clie return Promise.reject(err); } else { - const result: IZip__Result = Zip__ResultCodec.decode(input); + const result: Zip__Result = Zip__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/i64_service.solution.ts b/src/tests/unit/fixtures/thrift-server/i64_service.solution.ts index 27d28d5e..b384e5e8 100644 --- a/src/tests/unit/fixtures/thrift-server/i64_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/i64_service.solution.ts @@ -444,7 +444,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPeg__Result = Peg__ResultCodec.decode(input); + const result: Peg__Result = Peg__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); @@ -482,7 +482,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPong__Result = Pong__ResultCodec.decode(input); + const result: Pong__Result = Pong__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success); diff --git a/src/tests/unit/fixtures/thrift-server/resolved_field_service.solution.ts b/src/tests/unit/fixtures/thrift-server/resolved_field_service.solution.ts index d8a8e9f1..3f9c80d8 100644 --- a/src/tests/unit/fixtures/thrift-server/resolved_field_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/resolved_field_service.solution.ts @@ -200,7 +200,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPing__Result = Ping__ResultCodec.decode(input); + const result: Ping__Result = Ping__Result.read(input); input.readMessageEnd(); return Promise.resolve(result.success); } diff --git a/src/tests/unit/fixtures/thrift-server/throws_multi_service.solution.ts b/src/tests/unit/fixtures/thrift-server/throws_multi_service.solution.ts index 2afb8254..f033ca8a 100644 --- a/src/tests/unit/fixtures/thrift-server/throws_multi_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/throws_multi_service.solution.ts @@ -531,7 +531,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPeg__Result = Peg__ResultCodec.decode(input); + const result: Peg__Result = Peg__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); diff --git a/src/tests/unit/fixtures/thrift-server/throws_service.solution.ts b/src/tests/unit/fixtures/thrift-server/throws_service.solution.ts index eac00de7..49facecd 100644 --- a/src/tests/unit/fixtures/thrift-server/throws_service.solution.ts +++ b/src/tests/unit/fixtures/thrift-server/throws_service.solution.ts @@ -467,7 +467,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPeg__Result = Peg__ResultCodec.decode(input); + const result: Peg__Result = Peg__Result.read(input); input.readMessageEnd(); if (result.exp != null) { return Promise.reject(result.exp); @@ -508,7 +508,7 @@ export class Client extends thrift.ThriftClient { return Promise.reject(err); } else { - const result: IPong__Result = Pong__ResultCodec.decode(input); + const result: Pong__Result = Pong__Result.read(input); input.readMessageEnd(); if (result.success != null) { return Promise.resolve(result.success);