Skip to content

Commit 19df49a

Browse files
committed
chore: remove mapParams from serialize/deserialize
1 parent b3148b4 commit 19df49a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeDeserVisitor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ protected void deserializeMap(GenerationContext context, MapShape shape) {
7676

7777
// Get the right serialization for each entry in the map. Undefined
7878
// outputs won't have this deserializer invoked.
79-
writer.write("const mapParams: any = {};");
80-
writer.openBlock("Object.keys(output).forEach(key => {", "});", () -> {
79+
writer.openBlock("return Object.keys(output).reduce((acc: any, key: string) => {", "}, {});", () -> {
8180
// Dispatch to the output value provider for any additional handling.
82-
writer.write("mapParams[key] = $L;", target.accept(getMemberVisitor("output[key]")));
81+
writer.write("acc[key] = $L;", target.accept(getMemberVisitor("output[key]")));
82+
writer.write("return acc;");
8383
});
84-
writer.write("return mapParams;");
8584
}
8685

8786
@Override

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeSerVisitor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ public void serializeMap(GenerationContext context, MapShape shape) {
7979

8080
// Get the right serialization for each entry in the map. Undefined
8181
// inputs won't have this serializer invoked.
82-
writer.write("const mapParams: any = {};");
83-
writer.openBlock("Object.keys(input).forEach(key => {", "});", () -> {
82+
writer.openBlock("return Object.keys(input).reduce((acc: any, key: string) => {", "}, {});", () -> {
8483
// Dispatch to the input value provider for any additional handling.
85-
writer.write("mapParams[key] = $L;", target.accept(getMemberVisitor("input[key]")));
84+
writer.write("acc[key] = $L;", target.accept(getMemberVisitor("input[key]")));
85+
writer.write("return acc;");
8686
});
87-
writer.write("return mapParams;");
8887
}
8988

9089
@Override

0 commit comments

Comments
 (0)