Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/json_schema_compiler/js_util.py

Issue 2768213002: [Closure Externs] Add wrapping parens on optional params (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/js_externs_generator_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « tools/json_schema_compiler/js_externs_generator_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698