Skip to content

Commit

Permalink
fix: hack to fix maps with strict unions (any all the things)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-greene-ck committed Aug 12, 2019
1 parent 41fb9f4 commit c24475f
Show file tree
Hide file tree
Showing 57 changed files with 135 additions and 134 deletions.
3 changes: 2 additions & 1 deletion src/main/render/thrift-server/struct/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '../utils'

import {
createAnyType,
createVoidType,
thriftTypeForFieldType,
typeNodeForFieldType,
Expand All @@ -54,7 +55,7 @@ export function createTempVariables(
return [
createConstStatement(
COMMON_IDENTIFIERS.obj,
undefined,
createAnyType(),
ts.createObjectLiteral(
node.fields.map(
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IMyExceptionArgs {
}
export const MyExceptionCodec: thrift.IStructCodec<IMyExceptionArgs, IMyException> = {
encode(args: IMyExceptionArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
message: args.message,
code: (args.code != null ? args.code : 200)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IUserArgs {
}
export const UserCodec: thrift.IStructCodec<IUserArgs, IUser> = {
encode(args: IUserArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
name: args.name,
id: args.id
};
Expand Down Expand Up @@ -160,7 +160,7 @@ export interface IGetUser__ArgsArgs {
}
export const GetUser__ArgsCodec: thrift.IStructCodec<IGetUser__ArgsArgs, IGetUser__Args> = {
encode(args: IGetUser__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: args.id
};
output.writeStructBegin("GetUser__Args");
Expand Down Expand Up @@ -248,7 +248,7 @@ export interface ISaveUser__ArgsArgs {
}
export const SaveUser__ArgsCodec: thrift.IStructCodec<ISaveUser__ArgsArgs, ISaveUser__Args> = {
encode(args: ISaveUser__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
user: args.user
};
output.writeStructBegin("SaveUser__Args");
Expand Down Expand Up @@ -387,7 +387,7 @@ export interface IGetUser__ResultArgs {
}
export const GetUser__ResultCodec: thrift.IStructCodec<IGetUser__ResultArgs, IGetUser__Result> = {
encode(args: IGetUser__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetUser__Result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IMyStructArgs {
}
export const MyStructCodec: thrift.IStructCodec<IMyStructArgs, IMyStruct> = {
encode(args: IMyStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: (args.id != null ? args.id : 45),
bigID: (args.bigID != null ? (typeof args.bigID === "number" ? new thrift.Int64(args.bigID) : typeof args.bigID === "string" ? thrift.Int64.fromDecimalString(args.bigID) : args.bigID) : thrift.Int64.fromDecimalString("23948234"))
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface IMyUnionArgs {
export const MyUnionCodec: thrift.IStructCodec<IMyUnionArgs, IMyUnion> = {
encode(args: IMyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
field1: args.field1,
field2: (typeof args.field2 === "number" ? new thrift.Int64(args.field2) : typeof args.field2 === "string" ? thrift.Int64.fromDecimalString(args.field2) : args.field2)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IMyExceptionArgs {
}
export const MyExceptionCodec: thrift.IStructCodec<IMyExceptionArgs, IMyException> = {
encode(args: IMyExceptionArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
message: args.message,
code: (args.code != null ? args.code : 200)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IUserArgs {
}
export const UserCodec: thrift.IStructCodec<IUserArgs, IUser> = {
encode(args: IUserArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
name: args.name,
id: args.id
};
Expand Down Expand Up @@ -148,7 +148,7 @@ export interface IGetUser__ArgsArgs {
}
export const GetUser__ArgsCodec: thrift.IStructCodec<IGetUser__ArgsArgs, IGetUser__Args> = {
encode(args: IGetUser__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: args.id
};
output.writeStructBegin("GetUser__Args");
Expand Down Expand Up @@ -236,7 +236,7 @@ export interface ISaveUser__ArgsArgs {
}
export const SaveUser__ArgsCodec: thrift.IStructCodec<ISaveUser__ArgsArgs, ISaveUser__Args> = {
encode(args: ISaveUser__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
user: args.user
};
output.writeStructBegin("SaveUser__Args");
Expand Down Expand Up @@ -375,7 +375,7 @@ export interface IGetUser__ResultArgs {
}
export const GetUser__ResultCodec: thrift.IStructCodec<IGetUser__ResultArgs, IGetUser__Result> = {
encode(args: IGetUser__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetUser__Result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const MyUnionCodec: thrift.IStructToolkit<MyUnionArgs, MyUnion> = {
},
encode(args: MyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
field1: args.field1,
field2: (typeof args.field2 === "number" ? new thrift.Int64(args.field2) : typeof args.field2 === "string" ? thrift.Int64.fromDecimalString(args.field2) : args.field2)
};
Expand Down Expand Up @@ -187,7 +187,7 @@ export interface IGetUser__ArgsArgs {
}
export const GetUser__ArgsCodec: thrift.IStructCodec<IGetUser__ArgsArgs, IGetUser__Args> = {
encode(args: IGetUser__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
arg1: args.arg1
};
output.writeStructBegin("GetUser__Args");
Expand Down Expand Up @@ -326,7 +326,7 @@ export interface IGetUser__ResultArgs {
}
export const GetUser__ResultCodec: thrift.IStructCodec<IGetUser__ResultArgs, IGetUser__Result> = {
encode(args: IGetUser__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetUser__Result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface IMyStructArgs {
}
export const MyStructCodec: thrift.IStructCodec<IMyStructArgs, IMyStruct> = {
encode(args: IMyStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: args.id
};
output.writeStructBegin("MyStruct");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface IMyStructArgs {
}
export const MyStructCodec: thrift.IStructCodec<IMyStructArgs, IMyStruct> = {
encode(args: IMyStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: (args.id != null ? args.id : 45),
bigID: (args.bigID != null ? (typeof args.bigID === "number" ? new thrift.Int64(args.bigID) : typeof args.bigID === "string" ? thrift.Int64.fromDecimalString(args.bigID) : args.bigID) : thrift.Int64.fromDecimalString("23948234")),
word: args.word,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IMyUnionArgs {
export const MyUnionCodec: thrift.IStructCodec<IMyUnionArgs, IMyUnion> = {
encode(args: IMyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
option1: args.option1,
option2: (typeof args.option2 === "number" ? new thrift.Int64(args.option2) : typeof args.option2 === "string" ? thrift.Int64.fromDecimalString(args.option2) : args.option2)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface IMyUnionArgs {
export const MyUnionCodec: thrift.IStructCodec<IMyUnionArgs, IMyUnion> = {
encode(args: IMyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
option1: args.option1,
option2: (typeof args.option2 === "number" ? new thrift.Int64(args.option2) : typeof args.option2 === "string" ? thrift.Int64.fromDecimalString(args.option2) : args.option2)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const MyUnionCodec: thrift.IStructToolkit<MyUnionArgs, MyUnion> = {
},
encode(args: MyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
field1: args.field1,
field2: (typeof args.field2 === "number" ? new thrift.Int64(args.field2) : typeof args.field2 === "string" ? thrift.Int64.fromDecimalString(args.field2) : args.field2)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IOtherStructArgs {
}
export const OtherStructCodec: thrift.IStructCodec<IOtherStructArgs, IOtherStruct> = {
encode(args: IOtherStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
id: (typeof args.id === "number" ? new thrift.Int64(args.id) : typeof args.id === "string" ? thrift.Int64.fromDecimalString(args.id) : args.id),
name: (args.name != null ? (typeof args.name === "string" ? Buffer.from(args.name) : args.name) : Buffer.from("John"))
};
Expand Down Expand Up @@ -132,7 +132,7 @@ export interface IMyStructArgs {
}
export const MyStructCodec: thrift.IStructCodec<IMyStructArgs, IMyStruct> = {
encode(args: IMyStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
idList: args.idList,
idMap: args.idMap,
idMapList: args.idMapList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const MyUnionCodec: thrift.IStructToolkit<MyUnionArgs, MyUnion> = {
},
encode(args: MyUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
option1: args.option1,
option2: args.option2
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ICodeArgs {
}
export const CodeCodec: thrift.IStructCodec<ICodeArgs, ICode> = {
encode(args: ICodeArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
status: (typeof args.status === "number" ? new thrift.Int64(args.status) : typeof args.status === "string" ? thrift.Int64.fromDecimalString(args.status) : args.status)
};
output.writeStructBegin("Code");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface IGetUnion__ArgsArgs {
}
export const GetUnion__ArgsCodec: thrift.IStructCodec<IGetUnion__ArgsArgs, IGetUnion__Args> = {
encode(args: IGetUnion__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
index: args.index
};
output.writeStructBegin("GetUnion__Args");
Expand Down Expand Up @@ -180,7 +180,7 @@ export interface IGetUnion__ResultArgs {
}
export const GetUnion__ResultCodec: thrift.IStructCodec<IGetUnion__ResultArgs, IGetUnion__Result> = {
encode(args: IGetUnion__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetUnion__Result");
Expand Down Expand Up @@ -257,7 +257,7 @@ export interface IGetEnum__ResultArgs {
}
export const GetEnum__ResultCodec: thrift.IStructCodec<IGetEnum__ResultArgs, IGetEnum__Result> = {
encode(args: IGetEnum__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetEnum__Result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface IGetStruct__ArgsArgs {
}
export const GetStruct__ArgsCodec: thrift.IStructCodec<IGetStruct__ArgsArgs, IGetStruct__Args> = {
encode(args: IGetStruct__ArgsArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
key: args.key
};
output.writeStructBegin("GetStruct__Args");
Expand Down Expand Up @@ -117,7 +117,7 @@ export interface IGetStruct__ResultArgs {
}
export const GetStruct__ResultCodec: thrift.IStructCodec<IGetStruct__ResultArgs, IGetStruct__Result> = {
encode(args: IGetStruct__ResultArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
success: args.success
};
output.writeStructBegin("GetStruct__Result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ISharedStructArgs {
}
export const SharedStructCodec: thrift.IStructCodec<ISharedStructArgs, ISharedStruct> = {
encode(args: ISharedStructArgs, output: thrift.TProtocol): void {
const obj = {
const obj: any = {
code: args.code,
value: args.value
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const SharedUnionCodec: thrift.IStructToolkit<SharedUnionArgs, SharedUnio
},
encode(args: SharedUnionArgs, output: thrift.TProtocol): void {
let _fieldsSet: number = 0;
const obj = {
const obj: any = {
option1: args.option1,
option2: args.option2
};
Expand Down
Loading

0 comments on commit c24475f

Please sign in to comment.