diff --git a/tools/api-builder/typescript-package/processors/readTypeScriptModules.js b/tools/api-builder/typescript-package/processors/readTypeScriptModules.js index e9eeef74db..2445546a28 100644 --- a/tools/api-builder/typescript-package/processors/readTypeScriptModules.js +++ b/tools/api-builder/typescript-package/processors/readTypeScriptModules.js @@ -372,6 +372,14 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo, var sourceFile = ts.getSourceFileOfNode(declaration); if (declaration.type) { return getType(sourceFile, declaration.type).trim(); + } else if (declaration.initializer) { + // The symbol does not have a "type" but it is being initialized + // so we can deduce the type of from the initializer (mostly). + if (declaration.initializer.expression) { + return declaration.initializer.expression.text.trim(); + } else { + return getType(sourceFile, declaration.initializer).trim(); + } } }