Skip to content

Commit f6684e8

Browse files
committed
[doc_comment plugin] Allow documenting return type on return-less functions
Closes #566
1 parent c5d052a commit f6684e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

plugin/doc_comment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@
419419
fn.argNames[i] += "?";
420420
if (known) propagateWithWeight(known, fn.args[i]);
421421
}
422-
if (ret) propagateWithWeight(ret, fn.retval);
422+
if (ret) {
423+
if (fn.retval == infer.ANull) fn.retval = new infer.AVal;
424+
propagateWithWeight(ret, fn.retval);
425+
}
423426
if (self) propagateWithWeight(self, fn.self);
424427
} else if (type) {
425428
propagateWithWeight(type, aval);

test/cases/jsdoc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,10 @@ stringOrNumber; //: string|number
105105
function unionFunction(a) { return argh(); }
106106

107107
unionFunction; //: fn(a: string) -> [Foo|number]
108+
109+
/**
110+
* @returns {string}
111+
*/
112+
function ui() {}
113+
114+
ui(); //: string

0 commit comments

Comments
 (0)