Support nullable params and returns in generated externs
This commit is contained in:
@@ -103,11 +103,19 @@ exports.publish = function(data, opts) {
|
|||||||
if (typeof param.optional == 'boolean') {
|
if (typeof param.optional == 'boolean') {
|
||||||
paramInfo.optional = param.optional;
|
paramInfo.optional = param.optional;
|
||||||
}
|
}
|
||||||
|
if (typeof param.nullable == 'boolean') {
|
||||||
|
paramInfo.nullable = param.nullable;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
symbol.params = params;
|
symbol.params = params;
|
||||||
}
|
}
|
||||||
if (doc.returns) {
|
if (doc.returns) {
|
||||||
symbol.returns = getTypes(doc.returns[0].type.names);
|
symbol.returns = {
|
||||||
|
types: getTypes(doc.returns[0].type.names)
|
||||||
|
};
|
||||||
|
if (typeof doc.returns[0].nullable == 'boolean') {
|
||||||
|
symbol.returns.nullable = doc.returns[0].nullable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (doc.tags) {
|
if (doc.tags) {
|
||||||
doc.tags.every(function(tag) {
|
doc.tags.every(function(tag) {
|
||||||
|
|||||||
@@ -105,12 +105,14 @@ function generateExterns(typedefs, symbols, externs) {
|
|||||||
lines.push(' * @param {' +
|
lines.push(' * @param {' +
|
||||||
(param.variable ? '...' : '') +
|
(param.variable ? '...' : '') +
|
||||||
noGoogTypes(param.types).join('|') +
|
noGoogTypes(param.types).join('|') +
|
||||||
(param.optional ? '=' : '') +
|
(param.optional ? '=' : '') + (param.nullable ? '!' : '') +
|
||||||
'} ' + param.name);
|
'} ' + param.name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (symbol.returns) {
|
if (symbol.returns) {
|
||||||
lines.push(' * @return {' + noGoogTypes(symbol.returns).join('|') + '}');
|
lines.push(' * @return {' +
|
||||||
|
(symbol.returns.nullable ? '!' : '') +
|
||||||
|
noGoogTypes(symbol.returns.types).join('|') + '}');
|
||||||
}
|
}
|
||||||
if (symbol.template) {
|
if (symbol.template) {
|
||||||
lines.push(' * @template ' + symbol.template);
|
lines.push(' * @template ' + symbol.template);
|
||||||
|
|||||||
Reference in New Issue
Block a user