diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java index ee76483efb3..9edab34d0a1 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java @@ -106,6 +106,9 @@ void writeMembers(TypeScriptWriter writer, Shape shape) { String optionalSuffix = shape.isUnionShape() || !isRequiredMember(member) ? "?" : ""; String typeSuffix = requiredMemberMode == RequiredMemberMode.NULLABLE && isRequiredMember(member) ? " | undefined" : ""; + if (optionalSuffix.equals("?")) { + typeSuffix = " | undefined"; // support exactOptionalPropertyTypes. + } writer.write("${L}${L}${L}: ${T}${L};", memberPrefix, memberName, optionalSuffix, symbolProvider.toSymbol(member), typeSuffix); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java index da555865ac0..29601f09e15 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java @@ -558,7 +558,7 @@ public enum RequiredMemberMode { NULLABLE("nullable"), /** - * This will dissallow members marked as {@link RequiredTrait} to be {@code undefined}. + * This will disallow members marked as {@link RequiredTrait} to be {@code undefined}. * Use this mode with CAUTION because it comes with certain risks. When a server drops * {@link RequiredTrait} from an output shape (and it is replaced with {@link DefaultTrait} * as defined by the spec), if the server does not always serialize a value,