From 286db65d345482acc817d60a4dbd5e386ccb46e7 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sat, 9 Aug 2014 09:05:54 +0200 Subject: [PATCH] Use {*} instead of {goog.*} types in externs file --- tasks/generate-externs.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tasks/generate-externs.js b/tasks/generate-externs.js index e98cfbf56b..1962883aa0 100644 --- a/tasks/generate-externs.js +++ b/tasks/generate-externs.js @@ -65,6 +65,14 @@ function generateExterns(typedefs, symbols, externs) { return name; } + function noGoogTypes(typesWithGoog) { + typesWithoutGoog = []; + typesWithGoog.forEach(function(type) { + typesWithoutGoog.push(type.replace(/^goog\..*$/, '*')); + }); + return typesWithoutGoog; + } + function processSymbol(symbol) { addNamespaces(symbol.name.split('#')[0]); @@ -88,7 +96,7 @@ function generateExterns(typedefs, symbols, externs) { lines.push(' * @constructor'); } if (symbol.types) { - lines.push(' * @type {' + symbol.types.join('|') + '}'); + lines.push(' * @type {' + noGoogTypes(symbol.types).join('|') + '}'); } var args = []; if (symbol.params) { @@ -96,13 +104,13 @@ function generateExterns(typedefs, symbols, externs) { args.push(param.name); lines.push(' * @param {' + (param.variable ? '...' : '') + - param.types.join('|') + + noGoogTypes(param.types).join('|') + (param.optional ? '=' : '') + '} ' + param.name); }); } if (symbol.returns) { - lines.push(' * @return {' + symbol.returns.join('|') + '}'); + lines.push(' * @return {' + noGoogTypes(symbol.returns).join('|') + '}'); } if (symbol.template) { lines.push(' * @template ' + symbol.template); @@ -121,7 +129,7 @@ function generateExterns(typedefs, symbols, externs) { typedefs.forEach(function(typedef) { addNamespaces(typedef.name); lines.push('/**'); - lines.push(' * @typedef {' + typedef.types.join('|') + '}'); + lines.push(' * @typedef {' + noGoogTypes(typedef.types).join('|') + '}'); lines.push(' */'); lines.push(nameToJS(typedef.name) + ';'); lines.push('\n');