Index: tools/json_schema_compiler/js_util.py |
diff --git a/tools/json_schema_compiler/js_util.py b/tools/json_schema_compiler/js_util.py |
index 064b40b5e28be89a08b50e431355d1cf376c076b..e043f2efbac3d2ba188d4ab0600526a444505c10 100644 |
--- a/tools/json_schema_compiler/js_util.py |
+++ b/tools/json_schema_compiler/js_util.py |
@@ -118,9 +118,13 @@ class JsUtil(object): |
c = Code() |
c.Append('function(') |
for i, param in enumerate(function.params): |
- c.Concat(self._TypeToJsType(namespace_name, param.type_), new_line=False) |
+ t = self._TypeToJsType(namespace_name, param.type_) |
if param.optional: |
- c.Append('|undefined', new_line=False) |
+ c.Append('(', new_line=False) |
+ c.Concat(t, new_line=False) |
+ c.Append('|undefined)', new_line=False) |
+ else: |
+ c.Concat(t, new_line = False) |
if i is not len(function.params) - 1: |
c.Append(', ', new_line=False, strip_right=False) |
c.Append('):', new_line=False) |