Skip to content

Commit

Permalink
feat: allow undefined when property optional for exactOptionalPropert…
Browse files Browse the repository at this point in the history
…yTypes
  • Loading branch information
kuhe committed Nov 12, 2024
1 parent 0d9cee8 commit 87f0395
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 87f0395

Please sign in to comment.