Skip to content

Commit f8b415a

Browse files
committed
Mark optional fields as possibly being undefined
1 parent 2ddb76b commit f8b415a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cli/targets/static.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function buildFunction(type, functionName, gen, scope) {
208208

209209
if (config.beautify)
210210
code = beautifyCode(code);
211-
211+
212212
code = code.replace(/ {4}/g, "\t");
213213

214214
var hasScope = scope && Object.keys(scope).length;
@@ -307,7 +307,7 @@ function buildType(ref, type) {
307307
pushComment([
308308
field.comment || type.name + " " + field.name + ".",
309309
prop.charAt(0) !== "." ? "@name " + fullName + "#" + field.name : null,
310-
"@type {" + jsType + "}"
310+
"@type {" + jsType + (field.optional ? "|undefined": "") + "}"
311311
]);
312312
} else if (firstField) {
313313
push("");
@@ -389,7 +389,7 @@ function buildType(ref, type) {
389389
--indent;
390390
push("};");
391391
}
392-
392+
393393
if (config.encode) {
394394
push("");
395395
pushComment([

0 commit comments

Comments
 (0)