chore(doc-gen): improve error handling for missing declaration params

This commit is contained in:
Peter Bacon Darwin 2015-05-17 21:59:24 +01:00
parent 398e70ad39
commit 8c409e9251
1 changed files with 4 additions and 3 deletions

View File

@ -153,13 +153,14 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
return memberDoc; return memberDoc;
} }
function getParameters(typeChecker, symbol) { function getParameters(typeChecker, symbol) {
var declaration = symbol.valueDeclaration || symbol.declarations[0]; var declaration = symbol.valueDeclaration || symbol.declarations[0];
var sourceFile = ts.getSourceFileOfNode(declaration); var sourceFile = ts.getSourceFileOfNode(declaration);
if(!declaration.parameters) { if(!declaration.parameters) {
console.log(declaration); var location = getLocation(symbol);
throw 'missing declaration parameters'; throw new Error('missing declaration parameters for "' + symbol.name +
'" in ' + sourceFile.fileName +
' at line ' + location.start.line);
} }
var signature = typeChecker.getSignatureFromDeclaration(declaration); var signature = typeChecker.getSignatureFromDeclaration(declaration);
return declaration.parameters.map(function(parameter) { return declaration.parameters.map(function(parameter) {