Reputation: 1313
With Javascript function JSDocs, I've seen two different syntaxes for documenting the return values that can be nullable.
Let's say we have this function:
const getTitle = () => { // Can return string or null };
For this, which of the following JSDocs is correct:
Upvotes: 10
Views: 5845
Reputation: 28424
You can do this in two ways, the first preferred:
@returns {?string}
@returns {string|null}
Upvotes: 16