From 3af79134069ddecfa85fdb3acd75c016c085b46f Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Wed, 27 Oct 2021 20:00:48 -0500 Subject: [PATCH] Fix weird braces. --- integration/angular/simple-message.ts | 4 +- integration/avoid-import-conflicts/simple.ts | 12 +- integration/avoid-import-conflicts/simple2.ts | 8 +- integration/barrel-imports/bar.ts | 8 +- integration/barrel-imports/foo.ts | 4 +- integration/batching-with-context/batching.ts | 20 +- integration/batching/batching.ts | 20 +- integration/bytes-as-base64/message.ts | 4 +- integration/bytes-node/point.ts | 4 +- integration/const-enum/const-enum.ts | 4 +- .../generic-service-definitions/simple.ts | 4 +- integration/global-this/global-this.ts | 8 +- .../grpc-js/google/protobuf/timestamp.ts | 8 +- .../grpc-js/google/protobuf/wrappers.ts | 36 +--- integration/grpc-js/simple.ts | 4 +- integration/grpc-web-go-server/example.ts | 68 ++---- .../example.ts | 20 +- integration/grpc-web-no-streaming/example.ts | 20 +- integration/grpc-web/example.ts | 68 ++---- integration/lower-case-svc-methods/math.ts | 12 +- .../no-proto-package/no-proto-package.ts | 4 +- integration/oneof-properties/oneof.ts | 44 +--- integration/oneof-unions/oneof.ts | 24 +-- integration/point/point.ts | 8 +- integration/return-observable/observable.ts | 8 +- .../simple-deprecated-fields/simple.ts | 20 +- integration/simple-esmodule-interop/simple.ts | 56 ++--- .../google/protobuf/timestamp.ts | 8 +- .../google/protobuf/wrappers.ts | 36 +--- integration/simple-long-string/simple.ts | 56 ++--- .../simple-long/google/protobuf/wrappers.ts | 28 +-- integration/simple-long/simple.ts | 56 ++--- .../google/protobuf/timestamp.ts | 8 +- .../google/protobuf/wrappers.ts | 36 +--- .../simple-optionals/import_dir/thing.ts | 4 +- integration/simple-optionals/simple.ts | 144 ++++--------- integration/simple-optionals/thing.ts | 4 +- integration/simple-proto2/simple.ts | 4 +- .../simple-snake/google/protobuf/timestamp.ts | 8 +- .../simple-snake/google/protobuf/wrappers.ts | 36 +--- integration/simple-snake/import_dir/thing.ts | 4 +- integration/simple-snake/simple.ts | 144 ++++--------- integration/simple-string-enums/simple.ts | 8 +- .../google/protobuf/timestamp.ts | 8 +- .../google/protobuf/wrappers.ts | 36 +--- .../import_dir/thing.ts | 4 +- .../simple-unrecognized-enum/simple.ts | 144 ++++--------- .../simple/google/protobuf/timestamp.ts | 8 +- .../simple/google/protobuf/wrappers.ts | 36 +--- integration/simple/google/type/date.ts | 12 +- integration/simple/import_dir/thing.ts | 4 +- integration/simple/simple.ts | 200 +++++------------- integration/type-registry/foo.ts | 8 +- .../google/protobuf/timestamp.ts | 8 +- .../google/protobuf/timestamp.ts | 8 +- .../google/protobuf/timestamp.ts | 8 +- .../use-date-string/use-date-string.ts | 20 +- .../google/protobuf/timestamp.ts | 8 +- integration/use-date-true/use-date-true.ts | 20 +- integration/vector-tile/vector_tile.ts | 48 ++--- src/main.ts | 8 +- 61 files changed, 420 insertions(+), 1252 deletions(-) diff --git a/integration/angular/simple-message.ts b/integration/angular/simple-message.ts index 34b28fa36..7d17c402f 100644 --- a/integration/angular/simple-message.ts +++ b/integration/angular/simple-message.ts @@ -54,9 +54,7 @@ export const SimpleMessage = { fromPartial(object: DeepPartial): SimpleMessage { const message = { ...baseSimpleMessage } as SimpleMessage; - { - message.numberField = object.numberField ?? 0; - } + message.numberField = object.numberField ?? 0; return message; }, }; diff --git a/integration/avoid-import-conflicts/simple.ts b/integration/avoid-import-conflicts/simple.ts index 32031f412..b06a4bda3 100644 --- a/integration/avoid-import-conflicts/simple.ts +++ b/integration/avoid-import-conflicts/simple.ts @@ -117,9 +117,7 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.otherSimple !== undefined && object.otherSimple !== null) { message.otherSimple = Simple2.fromPartial(object.otherSimple); } else { @@ -187,12 +185,8 @@ export const SimpleEnums = { fromPartial(object: DeepPartial): SimpleEnums { const message = { ...baseSimpleEnums } as SimpleEnums; - { - message.localEnum = object.localEnum ?? 0; - } - { - message.importEnum = object.importEnum ?? 0; - } + message.localEnum = object.localEnum ?? 0; + message.importEnum = object.importEnum ?? 0; return message; }, }; diff --git a/integration/avoid-import-conflicts/simple2.ts b/integration/avoid-import-conflicts/simple2.ts index dc2fe29a0..8284e539f 100644 --- a/integration/avoid-import-conflicts/simple2.ts +++ b/integration/avoid-import-conflicts/simple2.ts @@ -105,12 +105,8 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; return message; }, }; diff --git a/integration/barrel-imports/bar.ts b/integration/barrel-imports/bar.ts index b7012044e..3cbfb3b15 100644 --- a/integration/barrel-imports/bar.ts +++ b/integration/barrel-imports/bar.ts @@ -65,12 +65,8 @@ export const Bar = { fromPartial(object: DeepPartial): Bar { const message = { ...baseBar } as Bar; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; return message; }, }; diff --git a/integration/barrel-imports/foo.ts b/integration/barrel-imports/foo.ts index 4b3b887fe..78c08c18a 100644 --- a/integration/barrel-imports/foo.ts +++ b/integration/barrel-imports/foo.ts @@ -66,9 +66,7 @@ export const Foo = { fromPartial(object: DeepPartial): Foo { const message = { ...baseFoo } as Foo; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.bar !== undefined && object.bar !== null) { message.bar = Bar.fromPartial(object.bar); } else { diff --git a/integration/batching-with-context/batching.ts b/integration/batching-with-context/batching.ts index 9dd994798..1afac519c 100644 --- a/integration/batching-with-context/batching.ts +++ b/integration/batching-with-context/batching.ts @@ -358,9 +358,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromPartial(object: DeepPartial): BatchMapQueryResponse_EntitiesEntry { const message = { ...baseBatchMapQueryResponse_EntitiesEntry } as BatchMapQueryResponse_EntitiesEntry; - { - message.key = object.key ?? ''; - } + message.key = object.key ?? ''; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -416,9 +414,7 @@ export const GetOnlyMethodRequest = { fromPartial(object: DeepPartial): GetOnlyMethodRequest { const message = { ...baseGetOnlyMethodRequest } as GetOnlyMethodRequest; - { - message.id = object.id ?? ''; - } + message.id = object.id ?? ''; return message; }, }; @@ -524,9 +520,7 @@ export const WriteMethodRequest = { fromPartial(object: DeepPartial): WriteMethodRequest { const message = { ...baseWriteMethodRequest } as WriteMethodRequest; - { - message.id = object.id ?? ''; - } + message.id = object.id ?? ''; return message; }, }; @@ -627,12 +621,8 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? ''; - } - { - message.name = object.name ?? ''; - } + message.id = object.id ?? ''; + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/batching/batching.ts b/integration/batching/batching.ts index fe99fe1ac..abf7f953a 100644 --- a/integration/batching/batching.ts +++ b/integration/batching/batching.ts @@ -356,9 +356,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromPartial(object: DeepPartial): BatchMapQueryResponse_EntitiesEntry { const message = { ...baseBatchMapQueryResponse_EntitiesEntry } as BatchMapQueryResponse_EntitiesEntry; - { - message.key = object.key ?? ''; - } + message.key = object.key ?? ''; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -414,9 +412,7 @@ export const GetOnlyMethodRequest = { fromPartial(object: DeepPartial): GetOnlyMethodRequest { const message = { ...baseGetOnlyMethodRequest } as GetOnlyMethodRequest; - { - message.id = object.id ?? ''; - } + message.id = object.id ?? ''; return message; }, }; @@ -522,9 +518,7 @@ export const WriteMethodRequest = { fromPartial(object: DeepPartial): WriteMethodRequest { const message = { ...baseWriteMethodRequest } as WriteMethodRequest; - { - message.id = object.id ?? ''; - } + message.id = object.id ?? ''; return message; }, }; @@ -625,12 +619,8 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? ''; - } - { - message.name = object.name ?? ''; - } + message.id = object.id ?? ''; + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/bytes-as-base64/message.ts b/integration/bytes-as-base64/message.ts index b5ea8b46e..6b5ebc662 100644 --- a/integration/bytes-as-base64/message.ts +++ b/integration/bytes-as-base64/message.ts @@ -29,9 +29,7 @@ export const Message = { fromPartial(object: DeepPartial): Message { const message = { ...baseMessage } as Message; - { - message.data = object.data ?? new Uint8Array(); - } + message.data = object.data ?? new Uint8Array(); return message; }, }; diff --git a/integration/bytes-node/point.ts b/integration/bytes-node/point.ts index c4bbe7fcc..1a37383ba 100644 --- a/integration/bytes-node/point.ts +++ b/integration/bytes-node/point.ts @@ -55,9 +55,7 @@ export const Point = { fromPartial(object: DeepPartial): Point { const message = { ...basePoint } as Point; - { - message.data = object.data ?? Buffer.alloc(0); - } + message.data = object.data ?? Buffer.alloc(0); return message; }, }; diff --git a/integration/const-enum/const-enum.ts b/integration/const-enum/const-enum.ts index bc06e58ec..2b59e47d5 100644 --- a/integration/const-enum/const-enum.ts +++ b/integration/const-enum/const-enum.ts @@ -113,9 +113,7 @@ export const DividerData = { fromPartial(object: DeepPartial): DividerData { const message = { ...baseDividerData } as DividerData; - { - message.type = object.type ?? DividerData_DividerType.DOUBLE; - } + message.type = object.type ?? DividerData_DividerType.DOUBLE; return message; }, }; diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index 4cd0ae8eb..5c8c2a568 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -54,9 +54,7 @@ export const TestMessage = { fromPartial(object: DeepPartial): TestMessage { const message = { ...baseTestMessage } as TestMessage; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; diff --git a/integration/global-this/global-this.ts b/integration/global-this/global-this.ts index 97f042b5a..8ce99ea98 100644 --- a/integration/global-this/global-this.ts +++ b/integration/global-this/global-this.ts @@ -58,9 +58,7 @@ export const Object = { fromPartial(object: DeepPartial): Object { const message = { ...baseObject } as Object; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -111,9 +109,7 @@ export const Error = { fromPartial(object: DeepPartial): Error { const message = { ...baseError } as Error; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/grpc-js/google/protobuf/wrappers.ts b/integration/grpc-js/google/protobuf/wrappers.ts index 2a334df51..5f52d3fe7 100644 --- a/integration/grpc-js/google/protobuf/wrappers.ts +++ b/integration/grpc-js/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/grpc-js/simple.ts b/integration/grpc-js/simple.ts index 0f1f16bd5..50138d1b7 100644 --- a/integration/grpc-js/simple.ts +++ b/integration/grpc-js/simple.ts @@ -85,9 +85,7 @@ export const TestMessage = { fromPartial(object: DeepPartial): TestMessage { const message = { ...baseTestMessage } as TestMessage; - { - message.timestamp = object.timestamp ?? undefined; - } + message.timestamp = object.timestamp ?? undefined; return message; }, }; diff --git a/integration/grpc-web-go-server/example.ts b/integration/grpc-web-go-server/example.ts index 44690ddfe..cab052ced 100644 --- a/integration/grpc-web-go-server/example.ts +++ b/integration/grpc-web-go-server/example.ts @@ -149,12 +149,8 @@ export const DashFlash = { fromPartial(object: DeepPartial): DashFlash { const message = { ...baseDashFlash } as DashFlash; - { - message.msg = object.msg ?? ''; - } - { - message.type = object.type ?? 0; - } + message.msg = object.msg ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -236,9 +232,7 @@ export const DashUserSettingsState = { fromPartial(object: DeepPartial): DashUserSettingsState { const message = { ...baseDashUserSettingsState } as DashUserSettingsState; - { - message.email = object.email ?? ''; - } + message.email = object.email ?? ''; if (object.urls !== undefined && object.urls !== null) { message.urls = DashUserSettingsState_URLs.fromPartial(object.urls); } else { @@ -312,12 +306,8 @@ export const DashUserSettingsState_URLs = { fromPartial(object: DeepPartial): DashUserSettingsState_URLs { const message = { ...baseDashUserSettingsState_URLs } as DashUserSettingsState_URLs; - { - message.connectGoogle = object.connectGoogle ?? ''; - } - { - message.connectGithub = object.connectGithub ?? ''; - } + message.connectGoogle = object.connectGoogle ?? ''; + message.connectGithub = object.connectGithub ?? ''; return message; }, }; @@ -404,18 +394,10 @@ export const DashCred = { fromPartial(object: DeepPartial): DashCred { const message = { ...baseDashCred } as DashCred; - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } - { - message.token = object.token ?? ''; - } - { - message.id = object.id ?? ''; - } + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; + message.token = object.token ?? ''; + message.id = object.id ?? ''; return message; }, }; @@ -478,12 +460,8 @@ export const DashAPICredsCreateReq = { fromPartial(object: DeepPartial): DashAPICredsCreateReq { const message = { ...baseDashAPICredsCreateReq } as DashAPICredsCreateReq; - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; return message; }, }; @@ -570,18 +548,10 @@ export const DashAPICredsUpdateReq = { fromPartial(object: DeepPartial): DashAPICredsUpdateReq { const message = { ...baseDashAPICredsUpdateReq } as DashAPICredsUpdateReq; - { - message.credSid = object.credSid ?? ''; - } - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } - { - message.id = object.id ?? ''; - } + message.credSid = object.credSid ?? ''; + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; + message.id = object.id ?? ''; return message; }, }; @@ -644,12 +614,8 @@ export const DashAPICredsDeleteReq = { fromPartial(object: DeepPartial): DashAPICredsDeleteReq { const message = { ...baseDashAPICredsDeleteReq } as DashAPICredsDeleteReq; - { - message.credSid = object.credSid ?? ''; - } - { - message.id = object.id ?? ''; - } + message.credSid = object.credSid ?? ''; + message.id = object.id ?? ''; return message; }, }; diff --git a/integration/grpc-web-no-streaming-observable/example.ts b/integration/grpc-web-no-streaming-observable/example.ts index c8b182e8b..a64377c43 100644 --- a/integration/grpc-web-no-streaming-observable/example.ts +++ b/integration/grpc-web-no-streaming-observable/example.ts @@ -128,12 +128,8 @@ export const DashFlash = { fromPartial(object: DeepPartial): DashFlash { const message = { ...baseDashFlash } as DashFlash; - { - message.msg = object.msg ?? ''; - } - { - message.type = object.type ?? 0; - } + message.msg = object.msg ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -215,9 +211,7 @@ export const DashUserSettingsState = { fromPartial(object: DeepPartial): DashUserSettingsState { const message = { ...baseDashUserSettingsState } as DashUserSettingsState; - { - message.email = object.email ?? ''; - } + message.email = object.email ?? ''; if (object.urls !== undefined && object.urls !== null) { message.urls = DashUserSettingsState_URLs.fromPartial(object.urls); } else { @@ -291,12 +285,8 @@ export const DashUserSettingsState_URLs = { fromPartial(object: DeepPartial): DashUserSettingsState_URLs { const message = { ...baseDashUserSettingsState_URLs } as DashUserSettingsState_URLs; - { - message.connectGoogle = object.connectGoogle ?? ''; - } - { - message.connectGithub = object.connectGithub ?? ''; - } + message.connectGoogle = object.connectGoogle ?? ''; + message.connectGithub = object.connectGithub ?? ''; return message; }, }; diff --git a/integration/grpc-web-no-streaming/example.ts b/integration/grpc-web-no-streaming/example.ts index 6e11c4d61..24a1d88a9 100644 --- a/integration/grpc-web-no-streaming/example.ts +++ b/integration/grpc-web-no-streaming/example.ts @@ -126,12 +126,8 @@ export const DashFlash = { fromPartial(object: DeepPartial): DashFlash { const message = { ...baseDashFlash } as DashFlash; - { - message.msg = object.msg ?? ''; - } - { - message.type = object.type ?? 0; - } + message.msg = object.msg ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -213,9 +209,7 @@ export const DashUserSettingsState = { fromPartial(object: DeepPartial): DashUserSettingsState { const message = { ...baseDashUserSettingsState } as DashUserSettingsState; - { - message.email = object.email ?? ''; - } + message.email = object.email ?? ''; if (object.urls !== undefined && object.urls !== null) { message.urls = DashUserSettingsState_URLs.fromPartial(object.urls); } else { @@ -289,12 +283,8 @@ export const DashUserSettingsState_URLs = { fromPartial(object: DeepPartial): DashUserSettingsState_URLs { const message = { ...baseDashUserSettingsState_URLs } as DashUserSettingsState_URLs; - { - message.connectGoogle = object.connectGoogle ?? ''; - } - { - message.connectGithub = object.connectGithub ?? ''; - } + message.connectGoogle = object.connectGoogle ?? ''; + message.connectGithub = object.connectGithub ?? ''; return message; }, }; diff --git a/integration/grpc-web/example.ts b/integration/grpc-web/example.ts index f415afb7e..90607b0ff 100644 --- a/integration/grpc-web/example.ts +++ b/integration/grpc-web/example.ts @@ -152,12 +152,8 @@ export const DashFlash = { fromPartial(object: DeepPartial): DashFlash { const message = { ...baseDashFlash } as DashFlash; - { - message.msg = object.msg ?? ''; - } - { - message.type = object.type ?? 0; - } + message.msg = object.msg ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -239,9 +235,7 @@ export const DashUserSettingsState = { fromPartial(object: DeepPartial): DashUserSettingsState { const message = { ...baseDashUserSettingsState } as DashUserSettingsState; - { - message.email = object.email ?? ''; - } + message.email = object.email ?? ''; if (object.urls !== undefined && object.urls !== null) { message.urls = DashUserSettingsState_URLs.fromPartial(object.urls); } else { @@ -315,12 +309,8 @@ export const DashUserSettingsState_URLs = { fromPartial(object: DeepPartial): DashUserSettingsState_URLs { const message = { ...baseDashUserSettingsState_URLs } as DashUserSettingsState_URLs; - { - message.connectGoogle = object.connectGoogle ?? ''; - } - { - message.connectGithub = object.connectGithub ?? ''; - } + message.connectGoogle = object.connectGoogle ?? ''; + message.connectGithub = object.connectGithub ?? ''; return message; }, }; @@ -407,18 +397,10 @@ export const DashCred = { fromPartial(object: DeepPartial): DashCred { const message = { ...baseDashCred } as DashCred; - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } - { - message.token = object.token ?? ''; - } - { - message.id = object.id ?? ''; - } + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; + message.token = object.token ?? ''; + message.id = object.id ?? ''; return message; }, }; @@ -481,12 +463,8 @@ export const DashAPICredsCreateReq = { fromPartial(object: DeepPartial): DashAPICredsCreateReq { const message = { ...baseDashAPICredsCreateReq } as DashAPICredsCreateReq; - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; return message; }, }; @@ -573,18 +551,10 @@ export const DashAPICredsUpdateReq = { fromPartial(object: DeepPartial): DashAPICredsUpdateReq { const message = { ...baseDashAPICredsUpdateReq } as DashAPICredsUpdateReq; - { - message.credSid = object.credSid ?? ''; - } - { - message.description = object.description ?? ''; - } - { - message.metadata = object.metadata ?? ''; - } - { - message.id = object.id ?? ''; - } + message.credSid = object.credSid ?? ''; + message.description = object.description ?? ''; + message.metadata = object.metadata ?? ''; + message.id = object.id ?? ''; return message; }, }; @@ -647,12 +617,8 @@ export const DashAPICredsDeleteReq = { fromPartial(object: DeepPartial): DashAPICredsDeleteReq { const message = { ...baseDashAPICredsDeleteReq } as DashAPICredsDeleteReq; - { - message.credSid = object.credSid ?? ''; - } - { - message.id = object.id ?? ''; - } + message.credSid = object.credSid ?? ''; + message.id = object.id ?? ''; return message; }, }; diff --git a/integration/lower-case-svc-methods/math.ts b/integration/lower-case-svc-methods/math.ts index 26f4ce552..cf2627864 100644 --- a/integration/lower-case-svc-methods/math.ts +++ b/integration/lower-case-svc-methods/math.ts @@ -77,12 +77,8 @@ export const NumPair = { fromPartial(object: DeepPartial): NumPair { const message = { ...baseNumPair } as NumPair; - { - message.num1 = object.num1 ?? 0; - } - { - message.num2 = object.num2 ?? 0; - } + message.num1 = object.num1 ?? 0; + message.num2 = object.num2 ?? 0; return message; }, }; @@ -133,9 +129,7 @@ export const NumSingle = { fromPartial(object: DeepPartial): NumSingle { const message = { ...baseNumSingle } as NumSingle; - { - message.num = object.num ?? 0; - } + message.num = object.num ?? 0; return message; }, }; diff --git a/integration/no-proto-package/no-proto-package.ts b/integration/no-proto-package/no-proto-package.ts index b2592bc55..dd4dfd44e 100644 --- a/integration/no-proto-package/no-proto-package.ts +++ b/integration/no-proto-package/no-proto-package.ts @@ -57,9 +57,7 @@ export const User = { fromPartial(object: DeepPartial): User { const message = { ...baseUser } as User; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/oneof-properties/oneof.ts b/integration/oneof-properties/oneof.ts index 4fb9d8a15..8a1a2e31a 100644 --- a/integration/oneof-properties/oneof.ts +++ b/integration/oneof-properties/oneof.ts @@ -239,41 +239,21 @@ export const PleaseChoose = { fromPartial(object: DeepPartial): PleaseChoose { const message = { ...basePleaseChoose } as PleaseChoose; - { - message.name = object.name ?? ''; - } - { - message.aNumber = object.aNumber ?? undefined; - } - { - message.aString = object.aString ?? undefined; - } + message.name = object.name ?? ''; + message.aNumber = object.aNumber ?? undefined; + message.aString = object.aString ?? undefined; if (object.aMessage !== undefined && object.aMessage !== null) { message.aMessage = PleaseChoose_Submessage.fromPartial(object.aMessage); } else { message.aMessage = undefined; } - { - message.aBool = object.aBool ?? undefined; - } - { - message.bunchaBytes = object.bunchaBytes ?? undefined; - } - { - message.anEnum = object.anEnum ?? undefined; - } - { - message.age = object.age ?? 0; - } - { - message.either = object.either ?? undefined; - } - { - message.or = object.or ?? undefined; - } - { - message.thirdOption = object.thirdOption ?? undefined; - } + message.aBool = object.aBool ?? undefined; + message.bunchaBytes = object.bunchaBytes ?? undefined; + message.anEnum = object.anEnum ?? undefined; + message.age = object.age ?? 0; + message.either = object.either ?? undefined; + message.or = object.or ?? undefined; + message.thirdOption = object.thirdOption ?? undefined; return message; }, }; @@ -324,9 +304,7 @@ export const PleaseChoose_Submessage = { fromPartial(object: DeepPartial): PleaseChoose_Submessage { const message = { ...basePleaseChoose_Submessage } as PleaseChoose_Submessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/oneof-unions/oneof.ts b/integration/oneof-unions/oneof.ts index b8cc25e8f..d0267744b 100644 --- a/integration/oneof-unions/oneof.ts +++ b/integration/oneof-unions/oneof.ts @@ -231,9 +231,7 @@ export const PleaseChoose = { fromPartial(object: DeepPartial): PleaseChoose { const message = { ...basePleaseChoose } as PleaseChoose; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.choice?.$case === 'aNumber' && object.choice?.aNumber !== undefined && object.choice?.aNumber !== null) { message.choice = { $case: 'aNumber', aNumber: object.choice.aNumber }; } @@ -260,9 +258,7 @@ export const PleaseChoose = { if (object.choice?.$case === 'anEnum' && object.choice?.anEnum !== undefined && object.choice?.anEnum !== null) { message.choice = { $case: 'anEnum', anEnum: object.choice.anEnum }; } - { - message.age = object.age ?? 0; - } + message.age = object.age ?? 0; if ( object.eitherOr?.$case === 'either' && object.eitherOr?.either !== undefined && @@ -280,9 +276,7 @@ export const PleaseChoose = { ) { message.eitherOr = { $case: 'thirdOption', thirdOption: object.eitherOr.thirdOption }; } - { - message.signature = object.signature ?? new Uint8Array(); - } + message.signature = object.signature ?? new Uint8Array(); return message; }, }; @@ -331,9 +325,7 @@ export const PleaseChoose_Submessage = { fromPartial(object: DeepPartial): PleaseChoose_Submessage { const message = { ...basePleaseChoose_Submessage } as PleaseChoose_Submessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -392,12 +384,8 @@ export const SimpleButOptional = { fromPartial(object: DeepPartial): SimpleButOptional { const message = { ...baseSimpleButOptional } as SimpleButOptional; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; return message; }, }; diff --git a/integration/point/point.ts b/integration/point/point.ts index 0e99cb18a..af3c42bd5 100644 --- a/integration/point/point.ts +++ b/integration/point/point.ts @@ -72,12 +72,8 @@ export const Point = { fromPartial(object: DeepPartial): Point { const message = { ...basePoint } as Point; - { - message.lat = object.lat ?? 0; - } - { - message.lng = object.lng ?? 0; - } + message.lat = object.lat ?? 0; + message.lng = object.lng ?? 0; return message; }, }; diff --git a/integration/return-observable/observable.ts b/integration/return-observable/observable.ts index f7835a545..1421c0efd 100644 --- a/integration/return-observable/observable.ts +++ b/integration/return-observable/observable.ts @@ -59,9 +59,7 @@ export const ProduceRequest = { fromPartial(object: DeepPartial): ProduceRequest { const message = { ...baseProduceRequest } as ProduceRequest; - { - message.ingredients = object.ingredients ?? ''; - } + message.ingredients = object.ingredients ?? ''; return message; }, }; @@ -112,9 +110,7 @@ export const ProduceReply = { fromPartial(object: DeepPartial): ProduceReply { const message = { ...baseProduceReply } as ProduceReply; - { - message.result = object.result ?? ''; - } + message.result = object.result ?? ''; return message; }, }; diff --git a/integration/simple-deprecated-fields/simple.ts b/integration/simple-deprecated-fields/simple.ts index 9b26bbd14..02cf008fc 100644 --- a/integration/simple-deprecated-fields/simple.ts +++ b/integration/simple-deprecated-fields/simple.ts @@ -126,23 +126,15 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.testField = object.testField ?? ''; - } - { - message.testNotDeprecated = object.testNotDeprecated ?? ''; - } + message.testField = object.testField ?? ''; + message.testNotDeprecated = object.testNotDeprecated ?? ''; return message; }, }; @@ -193,9 +185,7 @@ export const Child = { fromPartial(object: DeepPartial): Child { const message = { ...baseChild } as Child; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; diff --git a/integration/simple-esmodule-interop/simple.ts b/integration/simple-esmodule-interop/simple.ts index 1faf1b2d4..893eb0d71 100644 --- a/integration/simple-esmodule-interop/simple.ts +++ b/integration/simple-esmodule-interop/simple.ts @@ -82,12 +82,8 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; return message; }, }; @@ -283,42 +279,18 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? 0; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? 0; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? 0; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? 0; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? 0; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? 0; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? 0; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? 0; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? 0; return message; }, }; diff --git a/integration/simple-long-string/google/protobuf/timestamp.ts b/integration/simple-long-string/google/protobuf/timestamp.ts index b079d83c9..f9bcc2476 100644 --- a/integration/simple-long-string/google/protobuf/timestamp.ts +++ b/integration/simple-long-string/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? '0'; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? '0'; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/simple-long-string/google/protobuf/wrappers.ts b/integration/simple-long-string/google/protobuf/wrappers.ts index 7daee39b1..9ca672531 100644 --- a/integration/simple-long-string/google/protobuf/wrappers.ts +++ b/integration/simple-long-string/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? '0'; - } + message.value = object.value ?? '0'; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? '0'; - } + message.value = object.value ?? '0'; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple-long-string/simple.ts b/integration/simple-long-string/simple.ts index e62424f93..e36bf4842 100644 --- a/integration/simple-long-string/simple.ts +++ b/integration/simple-long-string/simple.ts @@ -238,48 +238,20 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? '0'; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? '0'; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? '0'; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? '0'; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? '0'; - } - { - message.guint64 = object.guint64 ?? undefined; - } - { - message.timestamp = object.timestamp ?? undefined; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? '0'; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? '0'; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? '0'; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? '0'; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? '0'; + message.guint64 = object.guint64 ?? undefined; + message.timestamp = object.timestamp ?? undefined; return message; }, }; diff --git a/integration/simple-long/google/protobuf/wrappers.ts b/integration/simple-long/google/protobuf/wrappers.ts index 70e3f27ce..f63d5b340 100644 --- a/integration/simple-long/google/protobuf/wrappers.ts +++ b/integration/simple-long/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -356,9 +352,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -409,9 +403,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -462,9 +454,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -515,9 +505,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -569,9 +557,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index a75b0be25..56d902e5e 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -164,15 +164,9 @@ export const SimpleWithWrappers = { fromPartial(object: DeepPartial): SimpleWithWrappers { const message = { ...baseSimpleWithWrappers } as SimpleWithWrappers; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.enabled = object.enabled ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.enabled = object.enabled ?? undefined; if (object.bananas !== undefined && object.bananas !== null) { message.bananas = object.bananas as Long | undefined; } else { @@ -350,12 +344,8 @@ export const SimpleWithMap_NameLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_NameLookupEntry { const message = { ...baseSimpleWithMap_NameLookupEntry } as SimpleWithMap_NameLookupEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? ''; - } + message.key = object.key ?? ''; + message.value = object.value ?? ''; return message; }, }; @@ -418,12 +408,8 @@ export const SimpleWithMap_IntLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_IntLookupEntry { const message = { ...baseSimpleWithMap_IntLookupEntry } as SimpleWithMap_IntLookupEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -647,47 +633,33 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; if (object.int64 !== undefined && object.int64 !== null) { message.int64 = object.int64 as Long; } else { message.int64 = Long.ZERO; } - { - message.uint32 = object.uint32 ?? 0; - } + message.uint32 = object.uint32 ?? 0; if (object.uint64 !== undefined && object.uint64 !== null) { message.uint64 = object.uint64 as Long; } else { message.uint64 = Long.UZERO; } - { - message.sint32 = object.sint32 ?? 0; - } + message.sint32 = object.sint32 ?? 0; if (object.sint64 !== undefined && object.sint64 !== null) { message.sint64 = object.sint64 as Long; } else { message.sint64 = Long.ZERO; } - { - message.fixed32 = object.fixed32 ?? 0; - } + message.fixed32 = object.fixed32 ?? 0; if (object.fixed64 !== undefined && object.fixed64 !== null) { message.fixed64 = object.fixed64 as Long; } else { message.fixed64 = Long.UZERO; } - { - message.sfixed32 = object.sfixed32 ?? 0; - } + message.sfixed32 = object.sfixed32 ?? 0; if (object.sfixed64 !== undefined && object.sfixed64 !== null) { message.sfixed64 = object.sfixed64 as Long; } else { diff --git a/integration/simple-optionals/google/protobuf/timestamp.ts b/integration/simple-optionals/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/simple-optionals/google/protobuf/timestamp.ts +++ b/integration/simple-optionals/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/simple-optionals/google/protobuf/wrappers.ts b/integration/simple-optionals/google/protobuf/wrappers.ts index 2a334df51..5f52d3fe7 100644 --- a/integration/simple-optionals/google/protobuf/wrappers.ts +++ b/integration/simple-optionals/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple-optionals/import_dir/thing.ts b/integration/simple-optionals/import_dir/thing.ts index c0eee8737..bc254a2a7 100644 --- a/integration/simple-optionals/import_dir/thing.ts +++ b/integration/simple-optionals/import_dir/thing.ts @@ -55,9 +55,7 @@ export const ImportedThing = { fromPartial(object: DeepPartial): ImportedThing { const message = { ...baseImportedThing } as ImportedThing; - { - message.createdAt = object.createdAt ?? undefined; - } + message.createdAt = object.createdAt ?? undefined; return message; }, }; diff --git a/integration/simple-optionals/simple.ts b/integration/simple-optionals/simple.ts index fe6844dbf..e1f10ef75 100644 --- a/integration/simple-optionals/simple.ts +++ b/integration/simple-optionals/simple.ts @@ -431,23 +431,15 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } - { - message.createdAt = object.createdAt ?? undefined; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; + message.createdAt = object.createdAt ?? undefined; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; message.grandChildren = []; if (object.grandChildren !== undefined && object.grandChildren !== null) { for (const e of object.grandChildren) { @@ -539,12 +531,8 @@ export const Child = { fromPartial(object: DeepPartial): Child { const message = { ...baseChild } as Child; - { - message.name = object.name ?? ''; - } - { - message.type = object.type ?? 0; - } + message.name = object.name ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -620,17 +608,13 @@ export const Nested = { fromPartial(object: DeepPartial): Nested { const message = { ...baseNested } as Nested; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.message !== undefined && object.message !== null) { message.message = Nested_InnerMessage.fromPartial(object.message); } else { message.message = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; return message; }, }; @@ -694,9 +678,7 @@ export const Nested_InnerMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage { const message = { ...baseNested_InnerMessage } as Nested_InnerMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.deep !== undefined && object.deep !== null) { message.deep = Nested_InnerMessage_DeepMessage.fromPartial(object.deep); } else { @@ -752,9 +734,7 @@ export const Nested_InnerMessage_DeepMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage_DeepMessage { const message = { ...baseNested_InnerMessage_DeepMessage } as Nested_InnerMessage_DeepMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -817,12 +797,8 @@ export const OneOfMessage = { fromPartial(object: DeepPartial): OneOfMessage { const message = { ...baseOneOfMessage } as OneOfMessage; - { - message.first = object.first ?? undefined; - } - { - message.last = object.last ?? undefined; - } + message.first = object.first ?? undefined; + message.last = object.last ?? undefined; return message; }, }; @@ -933,15 +909,9 @@ export const SimpleWithWrappers = { fromPartial(object: DeepPartial): SimpleWithWrappers { const message = { ...baseSimpleWithWrappers } as SimpleWithWrappers; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.enabled = object.enabled ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.enabled = object.enabled ?? undefined; message.coins = []; if (object.coins !== undefined && object.coins !== null) { for (const e of object.coins) { @@ -1004,9 +974,7 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? 0; - } + message.id = object.id ?? 0; return message; }, }; @@ -1197,9 +1165,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithMap_EntitiesByIdEntry { const message = { ...baseSimpleWithMap_EntitiesByIdEntry } as SimpleWithMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1267,12 +1233,8 @@ export const SimpleWithMap_NameLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_NameLookupEntry { const message = { ...baseSimpleWithMap_NameLookupEntry } as SimpleWithMap_NameLookupEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? ''; - } + message.key = object.key ?? ''; + message.value = object.value ?? ''; return message; }, }; @@ -1335,12 +1297,8 @@ export const SimpleWithMap_IntLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_IntLookupEntry { const message = { ...baseSimpleWithMap_IntLookupEntry } as SimpleWithMap_IntLookupEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -1471,9 +1429,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = { ...baseSimpleWithSnakeCaseMap_EntitiesByIdEntry } as SimpleWithSnakeCaseMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1529,9 +1485,7 @@ export const PingRequest = { fromPartial(object: DeepPartial): PingRequest { const message = { ...basePingRequest } as PingRequest; - { - message.input = object.input ?? ''; - } + message.input = object.input ?? ''; return message; }, }; @@ -1582,9 +1536,7 @@ export const PingResponse = { fromPartial(object: DeepPartial): PingResponse { const message = { ...basePingResponse } as PingResponse; - { - message.output = object.output ?? ''; - } + message.output = object.output ?? ''; return message; }, }; @@ -1780,42 +1732,18 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? 0; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? 0; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? 0; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? 0; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? 0; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? 0; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? 0; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? 0; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? 0; return message; }, }; diff --git a/integration/simple-optionals/thing.ts b/integration/simple-optionals/thing.ts index 2a13db33f..4ae43b0b7 100644 --- a/integration/simple-optionals/thing.ts +++ b/integration/simple-optionals/thing.ts @@ -55,9 +55,7 @@ export const ImportedThing = { fromPartial(object: DeepPartial): ImportedThing { const message = { ...baseImportedThing } as ImportedThing; - { - message.createdAt = object.createdAt ?? undefined; - } + message.createdAt = object.createdAt ?? undefined; return message; }, }; diff --git a/integration/simple-proto2/simple.ts b/integration/simple-proto2/simple.ts index 7f62dacee..6a675359c 100644 --- a/integration/simple-proto2/simple.ts +++ b/integration/simple-proto2/simple.ts @@ -86,9 +86,7 @@ export const Issue56 = { fromPartial(object: DeepPartial): Issue56 { const message = { ...baseIssue56 } as Issue56; - { - message.test = object.test ?? 1; - } + message.test = object.test ?? 1; return message; }, }; diff --git a/integration/simple-snake/google/protobuf/timestamp.ts b/integration/simple-snake/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/simple-snake/google/protobuf/timestamp.ts +++ b/integration/simple-snake/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/simple-snake/google/protobuf/wrappers.ts b/integration/simple-snake/google/protobuf/wrappers.ts index 2a334df51..5f52d3fe7 100644 --- a/integration/simple-snake/google/protobuf/wrappers.ts +++ b/integration/simple-snake/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple-snake/import_dir/thing.ts b/integration/simple-snake/import_dir/thing.ts index 9041fa33c..e482a30b8 100644 --- a/integration/simple-snake/import_dir/thing.ts +++ b/integration/simple-snake/import_dir/thing.ts @@ -55,9 +55,7 @@ export const ImportedThing = { fromPartial(object: DeepPartial): ImportedThing { const message = { ...baseImportedThing } as ImportedThing; - { - message.created_at = object.created_at ?? undefined; - } + message.created_at = object.created_at ?? undefined; return message; }, }; diff --git a/integration/simple-snake/simple.ts b/integration/simple-snake/simple.ts index 290bdd1c3..8db58bdea 100644 --- a/integration/simple-snake/simple.ts +++ b/integration/simple-snake/simple.ts @@ -431,23 +431,15 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } - { - message.created_at = object.created_at ?? undefined; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; + message.created_at = object.created_at ?? undefined; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; message.grand_children = []; if (object.grand_children !== undefined && object.grand_children !== null) { for (const e of object.grand_children) { @@ -539,12 +531,8 @@ export const Child = { fromPartial(object: DeepPartial): Child { const message = { ...baseChild } as Child; - { - message.name = object.name ?? ''; - } - { - message.type = object.type ?? 0; - } + message.name = object.name ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -620,17 +608,13 @@ export const Nested = { fromPartial(object: DeepPartial): Nested { const message = { ...baseNested } as Nested; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.message !== undefined && object.message !== null) { message.message = Nested_InnerMessage.fromPartial(object.message); } else { message.message = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; return message; }, }; @@ -694,9 +678,7 @@ export const Nested_InnerMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage { const message = { ...baseNested_InnerMessage } as Nested_InnerMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.deep !== undefined && object.deep !== null) { message.deep = Nested_InnerMessage_DeepMessage.fromPartial(object.deep); } else { @@ -752,9 +734,7 @@ export const Nested_InnerMessage_DeepMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage_DeepMessage { const message = { ...baseNested_InnerMessage_DeepMessage } as Nested_InnerMessage_DeepMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -817,12 +797,8 @@ export const OneOfMessage = { fromPartial(object: DeepPartial): OneOfMessage { const message = { ...baseOneOfMessage } as OneOfMessage; - { - message.first = object.first ?? undefined; - } - { - message.last = object.last ?? undefined; - } + message.first = object.first ?? undefined; + message.last = object.last ?? undefined; return message; }, }; @@ -933,15 +909,9 @@ export const SimpleWithWrappers = { fromPartial(object: DeepPartial): SimpleWithWrappers { const message = { ...baseSimpleWithWrappers } as SimpleWithWrappers; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.enabled = object.enabled ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.enabled = object.enabled ?? undefined; message.coins = []; if (object.coins !== undefined && object.coins !== null) { for (const e of object.coins) { @@ -1004,9 +974,7 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? 0; - } + message.id = object.id ?? 0; return message; }, }; @@ -1197,9 +1165,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithMap_EntitiesByIdEntry { const message = { ...baseSimpleWithMap_EntitiesByIdEntry } as SimpleWithMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1267,12 +1233,8 @@ export const SimpleWithMap_NameLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_NameLookupEntry { const message = { ...baseSimpleWithMap_NameLookupEntry } as SimpleWithMap_NameLookupEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? ''; - } + message.key = object.key ?? ''; + message.value = object.value ?? ''; return message; }, }; @@ -1335,12 +1297,8 @@ export const SimpleWithMap_IntLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_IntLookupEntry { const message = { ...baseSimpleWithMap_IntLookupEntry } as SimpleWithMap_IntLookupEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -1471,9 +1429,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = { ...baseSimpleWithSnakeCaseMap_EntitiesByIdEntry } as SimpleWithSnakeCaseMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1529,9 +1485,7 @@ export const PingRequest = { fromPartial(object: DeepPartial): PingRequest { const message = { ...basePingRequest } as PingRequest; - { - message.input = object.input ?? ''; - } + message.input = object.input ?? ''; return message; }, }; @@ -1582,9 +1536,7 @@ export const PingResponse = { fromPartial(object: DeepPartial): PingResponse { const message = { ...basePingResponse } as PingResponse; - { - message.output = object.output ?? ''; - } + message.output = object.output ?? ''; return message; }, }; @@ -1780,42 +1732,18 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? 0; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? 0; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? 0; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? 0; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? 0; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? 0; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? 0; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? 0; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? 0; return message; }, }; diff --git a/integration/simple-string-enums/simple.ts b/integration/simple-string-enums/simple.ts index bc1b8f8c4..beed80d91 100644 --- a/integration/simple-string-enums/simple.ts +++ b/integration/simple-string-enums/simple.ts @@ -146,12 +146,8 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.state = object.state ?? StateEnum.UNKNOWN; - } + message.name = object.name ?? ''; + message.state = object.state ?? StateEnum.UNKNOWN; message.states = []; if (object.states !== undefined && object.states !== null) { for (const e of object.states) { diff --git a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts index 2a334df51..5f52d3fe7 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple-unrecognized-enum/import_dir/thing.ts b/integration/simple-unrecognized-enum/import_dir/thing.ts index 527ac1a17..5ba6da998 100644 --- a/integration/simple-unrecognized-enum/import_dir/thing.ts +++ b/integration/simple-unrecognized-enum/import_dir/thing.ts @@ -55,9 +55,7 @@ export const ImportedThing = { fromPartial(object: DeepPartial): ImportedThing { const message = { ...baseImportedThing } as ImportedThing; - { - message.createdAt = object.createdAt ?? undefined; - } + message.createdAt = object.createdAt ?? undefined; return message; }, }; diff --git a/integration/simple-unrecognized-enum/simple.ts b/integration/simple-unrecognized-enum/simple.ts index cda6d70a4..bd45e247a 100644 --- a/integration/simple-unrecognized-enum/simple.ts +++ b/integration/simple-unrecognized-enum/simple.ts @@ -422,23 +422,15 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } - { - message.createdAt = object.createdAt ?? undefined; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; + message.createdAt = object.createdAt ?? undefined; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; message.grandChildren = []; if (object.grandChildren !== undefined && object.grandChildren !== null) { for (const e of object.grandChildren) { @@ -530,12 +522,8 @@ export const Child = { fromPartial(object: DeepPartial): Child { const message = { ...baseChild } as Child; - { - message.name = object.name ?? ''; - } - { - message.type = object.type ?? 0; - } + message.name = object.name ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -611,17 +599,13 @@ export const Nested = { fromPartial(object: DeepPartial): Nested { const message = { ...baseNested } as Nested; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.message !== undefined && object.message !== null) { message.message = Nested_InnerMessage.fromPartial(object.message); } else { message.message = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; return message; }, }; @@ -685,9 +669,7 @@ export const Nested_InnerMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage { const message = { ...baseNested_InnerMessage } as Nested_InnerMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.deep !== undefined && object.deep !== null) { message.deep = Nested_InnerMessage_DeepMessage.fromPartial(object.deep); } else { @@ -743,9 +725,7 @@ export const Nested_InnerMessage_DeepMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage_DeepMessage { const message = { ...baseNested_InnerMessage_DeepMessage } as Nested_InnerMessage_DeepMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -808,12 +788,8 @@ export const OneOfMessage = { fromPartial(object: DeepPartial): OneOfMessage { const message = { ...baseOneOfMessage } as OneOfMessage; - { - message.first = object.first ?? undefined; - } - { - message.last = object.last ?? undefined; - } + message.first = object.first ?? undefined; + message.last = object.last ?? undefined; return message; }, }; @@ -924,15 +900,9 @@ export const SimpleWithWrappers = { fromPartial(object: DeepPartial): SimpleWithWrappers { const message = { ...baseSimpleWithWrappers } as SimpleWithWrappers; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.enabled = object.enabled ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.enabled = object.enabled ?? undefined; message.coins = []; if (object.coins !== undefined && object.coins !== null) { for (const e of object.coins) { @@ -995,9 +965,7 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? 0; - } + message.id = object.id ?? 0; return message; }, }; @@ -1188,9 +1156,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithMap_EntitiesByIdEntry { const message = { ...baseSimpleWithMap_EntitiesByIdEntry } as SimpleWithMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1258,12 +1224,8 @@ export const SimpleWithMap_NameLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_NameLookupEntry { const message = { ...baseSimpleWithMap_NameLookupEntry } as SimpleWithMap_NameLookupEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? ''; - } + message.key = object.key ?? ''; + message.value = object.value ?? ''; return message; }, }; @@ -1326,12 +1288,8 @@ export const SimpleWithMap_IntLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_IntLookupEntry { const message = { ...baseSimpleWithMap_IntLookupEntry } as SimpleWithMap_IntLookupEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -1462,9 +1420,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = { ...baseSimpleWithSnakeCaseMap_EntitiesByIdEntry } as SimpleWithSnakeCaseMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1520,9 +1476,7 @@ export const PingRequest = { fromPartial(object: DeepPartial): PingRequest { const message = { ...basePingRequest } as PingRequest; - { - message.input = object.input ?? ''; - } + message.input = object.input ?? ''; return message; }, }; @@ -1573,9 +1527,7 @@ export const PingResponse = { fromPartial(object: DeepPartial): PingResponse { const message = { ...basePingResponse } as PingResponse; - { - message.output = object.output ?? ''; - } + message.output = object.output ?? ''; return message; }, }; @@ -1771,42 +1723,18 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? 0; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? 0; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? 0; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? 0; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? 0; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? 0; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? 0; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? 0; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? 0; return message; }, }; diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index c4f471bf1..a39e45400 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -171,12 +171,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/simple/google/protobuf/wrappers.ts b/integration/simple/google/protobuf/wrappers.ts index 2a334df51..5f52d3fe7 100644 --- a/integration/simple/google/protobuf/wrappers.ts +++ b/integration/simple/google/protobuf/wrappers.ts @@ -140,9 +140,7 @@ export const DoubleValue = { fromPartial(object: DeepPartial): DoubleValue { const message = { ...baseDoubleValue } as DoubleValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -193,9 +191,7 @@ export const FloatValue = { fromPartial(object: DeepPartial): FloatValue { const message = { ...baseFloatValue } as FloatValue; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -246,9 +242,7 @@ export const Int64Value = { fromPartial(object: DeepPartial): Int64Value { const message = { ...baseInt64Value } as Int64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -299,9 +293,7 @@ export const UInt64Value = { fromPartial(object: DeepPartial): UInt64Value { const message = { ...baseUInt64Value } as UInt64Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -352,9 +344,7 @@ export const Int32Value = { fromPartial(object: DeepPartial): Int32Value { const message = { ...baseInt32Value } as Int32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -405,9 +395,7 @@ export const UInt32Value = { fromPartial(object: DeepPartial): UInt32Value { const message = { ...baseUInt32Value } as UInt32Value; - { - message.value = object.value ?? 0; - } + message.value = object.value ?? 0; return message; }, }; @@ -458,9 +446,7 @@ export const BoolValue = { fromPartial(object: DeepPartial): BoolValue { const message = { ...baseBoolValue } as BoolValue; - { - message.value = object.value ?? false; - } + message.value = object.value ?? false; return message; }, }; @@ -511,9 +497,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = { ...baseStringValue } as StringValue; - { - message.value = object.value ?? ''; - } + message.value = object.value ?? ''; return message; }, }; @@ -565,9 +549,7 @@ export const BytesValue = { fromPartial(object: DeepPartial): BytesValue { const message = { ...baseBytesValue } as BytesValue; - { - message.value = object.value ?? new Uint8Array(); - } + message.value = object.value ?? new Uint8Array(); return message; }, }; diff --git a/integration/simple/google/type/date.ts b/integration/simple/google/type/date.ts index 6f591cc90..33b2865a3 100644 --- a/integration/simple/google/type/date.ts +++ b/integration/simple/google/type/date.ts @@ -105,15 +105,9 @@ export const DateMessage = { fromPartial(object: DeepPartial): DateMessage { const message = { ...baseDateMessage } as DateMessage; - { - message.year = object.year ?? 0; - } - { - message.month = object.month ?? 0; - } - { - message.day = object.day ?? 0; - } + message.year = object.year ?? 0; + message.month = object.month ?? 0; + message.day = object.day ?? 0; return message; }, }; diff --git a/integration/simple/import_dir/thing.ts b/integration/simple/import_dir/thing.ts index 527ac1a17..5ba6da998 100644 --- a/integration/simple/import_dir/thing.ts +++ b/integration/simple/import_dir/thing.ts @@ -55,9 +55,7 @@ export const ImportedThing = { fromPartial(object: DeepPartial): ImportedThing { const message = { ...baseImportedThing } as ImportedThing; - { - message.createdAt = object.createdAt ?? undefined; - } + message.createdAt = object.createdAt ?? undefined; return message; }, }; diff --git a/integration/simple/simple.ts b/integration/simple/simple.ts index f6f6305b9..5d5cf1861 100644 --- a/integration/simple/simple.ts +++ b/integration/simple/simple.ts @@ -524,23 +524,15 @@ export const Simple = { fromPartial(object: DeepPartial): Simple { const message = { ...baseSimple } as Simple; - { - message.name = object.name ?? ''; - } - { - message.age = object.age ?? 0; - } - { - message.createdAt = object.createdAt ?? undefined; - } + message.name = object.name ?? ''; + message.age = object.age ?? 0; + message.createdAt = object.createdAt ?? undefined; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; message.grandChildren = []; if (object.grandChildren !== undefined && object.grandChildren !== null) { for (const e of object.grandChildren) { @@ -581,9 +573,7 @@ export const Simple = { } else { message.birthday = undefined; } - { - message.blob = object.blob ?? new Uint8Array(); - } + message.blob = object.blob ?? new Uint8Array(); return message; }, }; @@ -646,12 +636,8 @@ export const Child = { fromPartial(object: DeepPartial): Child { const message = { ...baseChild } as Child; - { - message.name = object.name ?? ''; - } - { - message.type = object.type ?? 0; - } + message.name = object.name ?? ''; + message.type = object.type ?? 0; return message; }, }; @@ -727,17 +713,13 @@ export const Nested = { fromPartial(object: DeepPartial): Nested { const message = { ...baseNested } as Nested; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.message !== undefined && object.message !== null) { message.message = Nested_InnerMessage.fromPartial(object.message); } else { message.message = undefined; } - { - message.state = object.state ?? 0; - } + message.state = object.state ?? 0; return message; }, }; @@ -801,9 +783,7 @@ export const Nested_InnerMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage { const message = { ...baseNested_InnerMessage } as Nested_InnerMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; if (object.deep !== undefined && object.deep !== null) { message.deep = Nested_InnerMessage_DeepMessage.fromPartial(object.deep); } else { @@ -859,9 +839,7 @@ export const Nested_InnerMessage_DeepMessage = { fromPartial(object: DeepPartial): Nested_InnerMessage_DeepMessage { const message = { ...baseNested_InnerMessage_DeepMessage } as Nested_InnerMessage_DeepMessage; - { - message.name = object.name ?? ''; - } + message.name = object.name ?? ''; return message; }, }; @@ -924,12 +902,8 @@ export const OneOfMessage = { fromPartial(object: DeepPartial): OneOfMessage { const message = { ...baseOneOfMessage } as OneOfMessage; - { - message.first = object.first ?? undefined; - } - { - message.last = object.last ?? undefined; - } + message.first = object.first ?? undefined; + message.last = object.last ?? undefined; return message; }, }; @@ -1052,15 +1026,9 @@ export const SimpleWithWrappers = { fromPartial(object: DeepPartial): SimpleWithWrappers { const message = { ...baseSimpleWithWrappers } as SimpleWithWrappers; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.enabled = object.enabled ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.enabled = object.enabled ?? undefined; message.coins = []; if (object.coins !== undefined && object.coins !== null) { for (const e of object.coins) { @@ -1073,9 +1041,7 @@ export const SimpleWithWrappers = { message.snacks.push(e); } } - { - message.id = object.id ?? undefined; - } + message.id = object.id ?? undefined; return message; }, }; @@ -1126,9 +1092,7 @@ export const Entity = { fromPartial(object: DeepPartial): Entity { const message = { ...baseEntity } as Entity; - { - message.id = object.id ?? 0; - } + message.id = object.id ?? 0; return message; }, }; @@ -1411,9 +1375,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithMap_EntitiesByIdEntry { const message = { ...baseSimpleWithMap_EntitiesByIdEntry } as SimpleWithMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -1481,12 +1443,8 @@ export const SimpleWithMap_NameLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_NameLookupEntry { const message = { ...baseSimpleWithMap_NameLookupEntry } as SimpleWithMap_NameLookupEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? ''; - } + message.key = object.key ?? ''; + message.value = object.value ?? ''; return message; }, }; @@ -1549,12 +1507,8 @@ export const SimpleWithMap_IntLookupEntry = { fromPartial(object: DeepPartial): SimpleWithMap_IntLookupEntry { const message = { ...baseSimpleWithMap_IntLookupEntry } as SimpleWithMap_IntLookupEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -1617,12 +1571,8 @@ export const SimpleWithMap_MapOfTimestampsEntry = { fromPartial(object: DeepPartial): SimpleWithMap_MapOfTimestampsEntry { const message = { ...baseSimpleWithMap_MapOfTimestampsEntry } as SimpleWithMap_MapOfTimestampsEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? undefined; - } + message.key = object.key ?? ''; + message.value = object.value ?? undefined; return message; }, }; @@ -1686,12 +1636,8 @@ export const SimpleWithMap_MapOfBytesEntry = { fromPartial(object: DeepPartial): SimpleWithMap_MapOfBytesEntry { const message = { ...baseSimpleWithMap_MapOfBytesEntry } as SimpleWithMap_MapOfBytesEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? new Uint8Array(); - } + message.key = object.key ?? ''; + message.value = object.value ?? new Uint8Array(); return message; }, }; @@ -1754,12 +1700,8 @@ export const SimpleWithMap_MapOfStringValuesEntry = { fromPartial(object: DeepPartial): SimpleWithMap_MapOfStringValuesEntry { const message = { ...baseSimpleWithMap_MapOfStringValuesEntry } as SimpleWithMap_MapOfStringValuesEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? undefined; - } + message.key = object.key ?? ''; + message.value = object.value ?? undefined; return message; }, }; @@ -1890,9 +1832,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { fromPartial(object: DeepPartial): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = { ...baseSimpleWithSnakeCaseMap_EntitiesByIdEntry } as SimpleWithSnakeCaseMap_EntitiesByIdEntry; - { - message.key = object.key ?? 0; - } + message.key = object.key ?? 0; if (object.value !== undefined && object.value !== null) { message.value = Entity.fromPartial(object.value); } else { @@ -2028,12 +1968,8 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { fromPartial(object: DeepPartial): SimpleWithMapOfEnums_EnumsByIdEntry { const message = { ...baseSimpleWithMapOfEnums_EnumsByIdEntry } as SimpleWithMapOfEnums_EnumsByIdEntry; - { - message.key = object.key ?? 0; - } - { - message.value = object.value ?? 0; - } + message.key = object.key ?? 0; + message.value = object.value ?? 0; return message; }, }; @@ -2084,9 +2020,7 @@ export const PingRequest = { fromPartial(object: DeepPartial): PingRequest { const message = { ...basePingRequest } as PingRequest; - { - message.input = object.input ?? ''; - } + message.input = object.input ?? ''; return message; }, }; @@ -2137,9 +2071,7 @@ export const PingResponse = { fromPartial(object: DeepPartial): PingResponse { const message = { ...basePingResponse } as PingResponse; - { - message.output = object.output ?? ''; - } + message.output = object.output ?? ''; return message; }, }; @@ -2335,42 +2267,18 @@ export const Numbers = { fromPartial(object: DeepPartial): Numbers { const message = { ...baseNumbers } as Numbers; - { - message.double = object.double ?? 0; - } - { - message.float = object.float ?? 0; - } - { - message.int32 = object.int32 ?? 0; - } - { - message.int64 = object.int64 ?? 0; - } - { - message.uint32 = object.uint32 ?? 0; - } - { - message.uint64 = object.uint64 ?? 0; - } - { - message.sint32 = object.sint32 ?? 0; - } - { - message.sint64 = object.sint64 ?? 0; - } - { - message.fixed32 = object.fixed32 ?? 0; - } - { - message.fixed64 = object.fixed64 ?? 0; - } - { - message.sfixed32 = object.sfixed32 ?? 0; - } - { - message.sfixed64 = object.sfixed64 ?? 0; - } + message.double = object.double ?? 0; + message.float = object.float ?? 0; + message.int32 = object.int32 ?? 0; + message.int64 = object.int64 ?? 0; + message.uint32 = object.uint32 ?? 0; + message.uint64 = object.uint64 ?? 0; + message.sint32 = object.sint32 ?? 0; + message.sint64 = object.sint64 ?? 0; + message.fixed32 = object.fixed32 ?? 0; + message.fixed64 = object.fixed64 ?? 0; + message.sfixed32 = object.sfixed32 ?? 0; + message.sfixed64 = object.sfixed64 ?? 0; return message; }, }; @@ -2495,23 +2403,15 @@ export const SimpleButOptional = { fromPartial(object: DeepPartial): SimpleButOptional { const message = { ...baseSimpleButOptional } as SimpleButOptional; - { - message.name = object.name ?? undefined; - } - { - message.age = object.age ?? undefined; - } - { - message.createdAt = object.createdAt ?? undefined; - } + message.name = object.name ?? undefined; + message.age = object.age ?? undefined; + message.createdAt = object.createdAt ?? undefined; if (object.child !== undefined && object.child !== null) { message.child = Child.fromPartial(object.child); } else { message.child = undefined; } - { - message.state = object.state ?? undefined; - } + message.state = object.state ?? undefined; if (object.thing !== undefined && object.thing !== null) { message.thing = ImportedThing.fromPartial(object.thing); } else { diff --git a/integration/type-registry/foo.ts b/integration/type-registry/foo.ts index e7400c2a4..a046a04e2 100644 --- a/integration/type-registry/foo.ts +++ b/integration/type-registry/foo.ts @@ -64,9 +64,7 @@ export const Foo = { fromPartial(object: DeepPartial): Foo { const message = { ...baseFoo } as Foo; - { - message.timestamp = object.timestamp ?? undefined; - } + message.timestamp = object.timestamp ?? undefined; return message; }, }; @@ -121,9 +119,7 @@ export const Foo2 = { fromPartial(object: DeepPartial): Foo2 { const message = { ...baseFoo2 } as Foo2; - { - message.timestamp = object.timestamp ?? undefined; - } + message.timestamp = object.timestamp ?? undefined; return message; }, }; diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index f18d020e6..f464d4aae 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -166,12 +166,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/use-date-false/google/protobuf/timestamp.ts b/integration/use-date-false/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/use-date-false/google/protobuf/timestamp.ts +++ b/integration/use-date-false/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/use-date-string/use-date-string.ts b/integration/use-date-string/use-date-string.ts index dabf8d37e..23661339b 100644 --- a/integration/use-date-string/use-date-string.ts +++ b/integration/use-date-string/use-date-string.ts @@ -128,21 +128,15 @@ export const Todo = { fromPartial(object: DeepPartial): Todo { const message = { ...baseTodo } as Todo; - { - message.id = object.id ?? ''; - } - { - message.timestamp = object.timestamp ?? undefined; - } + message.id = object.id ?? ''; + message.timestamp = object.timestamp ?? undefined; message.repeatedTimestamp = []; if (object.repeatedTimestamp !== undefined && object.repeatedTimestamp !== null) { for (const e of object.repeatedTimestamp) { message.repeatedTimestamp.push(e); } } - { - message.optionalTimestamp = object.optionalTimestamp ?? undefined; - } + message.optionalTimestamp = object.optionalTimestamp ?? undefined; message.mapOfTimestamps = {}; if (object.mapOfTimestamps !== undefined && object.mapOfTimestamps !== null) { Object.entries(object.mapOfTimestamps).forEach(([key, value]) => { @@ -213,12 +207,8 @@ export const Todo_MapOfTimestampsEntry = { fromPartial(object: DeepPartial): Todo_MapOfTimestampsEntry { const message = { ...baseTodo_MapOfTimestampsEntry } as Todo_MapOfTimestampsEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? undefined; - } + message.key = object.key ?? ''; + message.value = object.value ?? undefined; return message; }, }; diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index 91b3fe28a..89f9a4fdb 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -162,12 +162,8 @@ export const Timestamp = { fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; - { - message.seconds = object.seconds ?? 0; - } - { - message.nanos = object.nanos ?? 0; - } + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; return message; }, }; diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index 4ef512bdd..f535467cf 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -128,21 +128,15 @@ export const Todo = { fromPartial(object: DeepPartial): Todo { const message = { ...baseTodo } as Todo; - { - message.id = object.id ?? ''; - } - { - message.timestamp = object.timestamp ?? undefined; - } + message.id = object.id ?? ''; + message.timestamp = object.timestamp ?? undefined; message.repeatedTimestamp = []; if (object.repeatedTimestamp !== undefined && object.repeatedTimestamp !== null) { for (const e of object.repeatedTimestamp) { message.repeatedTimestamp.push(e); } } - { - message.optionalTimestamp = object.optionalTimestamp ?? undefined; - } + message.optionalTimestamp = object.optionalTimestamp ?? undefined; message.mapOfTimestamps = {}; if (object.mapOfTimestamps !== undefined && object.mapOfTimestamps !== null) { Object.entries(object.mapOfTimestamps).forEach(([key, value]) => { @@ -213,12 +207,8 @@ export const Todo_MapOfTimestampsEntry = { fromPartial(object: DeepPartial): Todo_MapOfTimestampsEntry { const message = { ...baseTodo_MapOfTimestampsEntry } as Todo_MapOfTimestampsEntry; - { - message.key = object.key ?? ''; - } - { - message.value = object.value ?? undefined; - } + message.key = object.key ?? ''; + message.value = object.value ?? undefined; return message; }, }; diff --git a/integration/vector-tile/vector_tile.ts b/integration/vector-tile/vector_tile.ts index b95e56126..d67538767 100644 --- a/integration/vector-tile/vector_tile.ts +++ b/integration/vector-tile/vector_tile.ts @@ -266,27 +266,13 @@ export const Tile_Value = { fromPartial(object: DeepPartial): Tile_Value { const message = { ...baseTile_Value } as Tile_Value; - { - message.stringValue = object.stringValue ?? ''; - } - { - message.floatValue = object.floatValue ?? 0; - } - { - message.doubleValue = object.doubleValue ?? 0; - } - { - message.intValue = object.intValue ?? 0; - } - { - message.uintValue = object.uintValue ?? 0; - } - { - message.sintValue = object.sintValue ?? 0; - } - { - message.boolValue = object.boolValue ?? false; - } + message.stringValue = object.stringValue ?? ''; + message.floatValue = object.floatValue ?? 0; + message.doubleValue = object.doubleValue ?? 0; + message.intValue = object.intValue ?? 0; + message.uintValue = object.uintValue ?? 0; + message.sintValue = object.sintValue ?? 0; + message.boolValue = object.boolValue ?? false; return message; }, }; @@ -403,18 +389,14 @@ export const Tile_Feature = { fromPartial(object: DeepPartial): Tile_Feature { const message = { ...baseTile_Feature } as Tile_Feature; - { - message.id = object.id ?? 0; - } + message.id = object.id ?? 0; message.tags = []; if (object.tags !== undefined && object.tags !== null) { for (const e of object.tags) { message.tags.push(e); } } - { - message.type = object.type ?? 0; - } + message.type = object.type ?? 0; message.geometry = []; if (object.geometry !== undefined && object.geometry !== null) { for (const e of object.geometry) { @@ -549,12 +531,8 @@ export const Tile_Layer = { fromPartial(object: DeepPartial): Tile_Layer { const message = { ...baseTile_Layer } as Tile_Layer; - { - message.version = object.version ?? 0; - } - { - message.name = object.name ?? ''; - } + message.version = object.version ?? 0; + message.name = object.name ?? ''; message.features = []; if (object.features !== undefined && object.features !== null) { for (const e of object.features) { @@ -573,9 +551,7 @@ export const Tile_Layer = { message.values.push(Tile_Value.fromPartial(e)); } } - { - message.extent = object.extent ?? 0; - } + message.extent = object.extent ?? 0; return message; }, }; diff --git a/src/main.ts b/src/main.ts index 2b1eb0ae1..f24269c51 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1127,7 +1127,6 @@ function generateToJson(ctx: Context, fullName: string, messageDesc: DescriptorP chunks.push(code`message.${fieldName} !== undefined && (obj.${fieldName} = ${v});`); } }); - chunks.push(code`return obj;`); chunks.push(code`}`); return joinCode(chunks, { on: '\n' }); @@ -1209,6 +1208,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri } `); } + chunks.push(code`}`); } else if (isWithinOneOfThatShouldBeUnion(options, field)) { let oneofName = maybeSnakeToCamel(messageDesc.oneofDecl[field.oneofIndex].name, options); const v = readSnippet(`object.${oneofName}.${fieldName}`); @@ -1219,6 +1219,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri && object.${oneofName}?.${fieldName} !== null ) { message.${oneofName} = { $case: '${fieldName}', ${fieldName}: ${v} }; + } `); } else if ((isLong(field) || isLongValueType(field)) && options.forceLong === LongOption.LONG) { const v = readSnippet(`object.${fieldName}`); @@ -1228,13 +1229,13 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri chunks.push(code`} else {`); const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); chunks.push(code`message.${fieldName} = ${fallback}`); + chunks.push(code`}`); } else if ( isPrimitive(field) || (isTimestamp(field) && (options.useDate === DateOption.DATE || options.useDate === DateOption.STRING)) || isValueType(ctx, field) ) { // An optimized case of the else below that works when `readSnippet` returns the plain input - chunks.push(code`{`); // Without this extra scope the code generation breaks 🤷. We don't really need it. const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); chunks.push(code`message.${fieldName} = object.${fieldName} ?? ${fallback};`); } else { @@ -1243,9 +1244,8 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri chunks.push(code`} else {`); const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); chunks.push(code`message.${fieldName} = ${fallback}`); + chunks.push(code`}`); } - - chunks.push(code`}`); }); // and then wrap up the switch/while/return