Skip to content

Commit

Permalink
🏗 Add missing return types in build-system/ (ampproject#23749)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored Aug 7, 2019
1 parent 2fece85 commit cc4c6a6
Show file tree
Hide file tree
Showing 34 changed files with 60 additions and 62 deletions.
2 changes: 1 addition & 1 deletion build-system/amp4test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ app.get('/a4a/:bid', (req, res) => {

/**
* @param {{body: string, css: string|undefined, extensions: Array<string>|undefined, head: string|undefined, spec: string|undefined}} config
* @return {*} TODO(#23582): Specify return type
* @return {string}
*/
function composeDocument(config) {
const {body, css, extensions, head, spec, mode} = config;
Expand Down
2 changes: 1 addition & 1 deletion build-system/app-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const isRtvMode = serveMode => {
* @param {string=} hostName
* @param {boolean=} inabox
* @param {boolean=} storyV1
* @return {*} TODO(#23582): Specify return type
* @return {string}
*/
const replaceUrls = (mode, file, hostName, inabox, storyV1) => {
hostName = hostName || '';
Expand Down
2 changes: 1 addition & 1 deletion build-system/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ app.use('/shadow/', (req, res) => {
/**
* @param {string} ampJsVersion
* @param {string} file
* @return {*} TODO(#23582): Specify return type
* @return {string}
*/
function addViewerIntegrationScript(ampJsVersion, file) {
ampJsVersion = parseFloat(ampJsVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Changes the values of IS_DEV to false and IS_MINIFIED to true.
* The above said variables are in src/mode.js file.
* @param {Object} babelTypes
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
module.exports = function({types: t}) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Changes the values of IS_DEV to false and IS_MINIFIED to true.
* The above said variables are in src/mode.js file.
* @param {Object} babelTypes
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
module.exports = function(babelTypes) {
const {types: t} = babelTypes;
Expand Down
2 changes: 1 addition & 1 deletion build-system/compile/closure-compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let compilerErrors = '';
* dropping the closure compiler plugin's logging prefix and then syntax
* highlighting the error text.
* @param {string} message
* @return {*} TODO(#23582): Specify return type
* @return {string}
*/
function formatClosureCompilerError(message) {
const closurePluginLoggingPrefix = /^.*?gulp-google-closure-compiler.*?: /;
Expand Down
6 changes: 3 additions & 3 deletions build-system/compile/shorten-license.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const PATHS = [
/**
* We can replace full-text of standard licenses with a pre-approved shorten
* version.
* @return {*} TODO(#23582): Specify return type
* @return {!Pumpify}
*/
exports.shortenLicense = function() {
const streams = LICENSES.map(tuple => {
Expand All @@ -86,8 +86,8 @@ exports.shortenLicense = function() {

/**
* Returns true if a source file has a license that needs to be shortened.
* @param {Vinyl} file
* @return {*} TODO(#23582): Specify return type
* @param {!Vinyl} file
* @return {boolean}
*/
exports.shouldShortenLicense = function(file) {
return PATHS.some(path => file.path.endsWith(path));
Expand Down
2 changes: 1 addition & 1 deletion build-system/ctrlcHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const killSuffix = process.platform == 'win32' ? '>NUL' : '';
* the ongoing `gulp watch | build | dist` task.
*
* @param {string} command
* @return {*} TODO(#23582): Specify return type
* @return {number}
*/
exports.createCtrlcHandler = function(command) {
if (!isTravisBuild()) {
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/await-expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* expect(actual).to.equal(expected);
* Good:
* await expect(actual).to.equal(expected);
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
module.exports = function(context) {
return {
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/no-deep-destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* const { x: { y } } = obj.prop;
* Good:
* const { y } = obj.prop.x;
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
module.exports = function(context) {
return {
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/private-prop-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Enforces naming rules for private properties.
*
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
module.exports = function(context) {
/**
Expand Down
2 changes: 1 addition & 1 deletion build-system/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function exec(cmd, options) {
*
* @param {string} script
* @param {?Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Object}
*/
function execScriptAsync(script, options) {
return childProcess.spawn(shellCmd, [shellFlag, script], options);
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const {isTravisBuild} = require('../travis');

/**
* Runs ava tests.
* @return {*} TODO(#23582): Specify return type
* @return {!Vinyl}
*/
async function ava() {
return gulp
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/babel-plugin-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const {isTravisBuild} = require('../travis');

/**
* Simple wrapper around the jest tests for custom babel plugins.
* @return {*} TODO(#23582): Specify return type
* @return {!Vinyl}
*/
function babelPluginTests() {
return gulp.src('./build-system/babel-plugins/testSetupFile.js').pipe(
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/check-exact-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const checkerExecutable = 'npx npm-exact-versions';

/**
* Makes sure all package.json files in the repo use exact versions.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function checkExactVersions() {
let success = true;
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const del = require('del');

/**
* Clean up the build artifacts
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function clean() {
return del([
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function compileCss(watch, opt_compileAll) {
* @param {string} outJs
* @param {string} outCss
* @param {boolean} append
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function writeCssEntryPoint(path, outJs, outCss, append) {
return jsifyCssAsync(`css/${path}`).then(css =>
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/dep-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function toArrayOrDefault(value, defaultValue) {
* Flatten array of arrays.
*
* @param {!Array<!Array>} arr
* @return {*} TODO(#23582): Specify return type
* @return {!Array}
*/
function flatten(arr) {
return [].concat.apply([], arr);
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/dev-dashboard-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {isTravisBuild} = require('../travis');

/**
* Run all the dev dashboard tests
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function devDashboardTests() {
const mocha = new Mocha({reporter: isTravisBuild() ? 'dot' : 'spec'});
Expand Down
8 changes: 4 additions & 4 deletions build-system/tasks/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async function dist() {
* Build AMP experiments.js.
*
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildExperiments(options) {
return compileJs(
Expand All @@ -196,7 +196,7 @@ function buildExperiments(options) {
*
* @param {string} version
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildLoginDone(version, options) {
const buildDir = `build/all/amp-access-${version}/`;
Expand All @@ -220,7 +220,7 @@ function buildLoginDone(version, options) {
* Build amp-web-push publisher files HTML page.
*
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildWebPushPublisherFiles(options) {
const distDir = 'dist/v0';
Expand Down Expand Up @@ -355,7 +355,7 @@ function postBuildWebPushPublisherFilesVersion() {

/**
* Precompilation steps required to build experiment js binaries.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function preBuildExperiments() {
const path = 'tools/experiments';
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/e2e/controller-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ControllerPromise {
* the inner opt_mutate function.
* @param {function(TYPE,function(TYPE): ?TYPE): !Promise=} wait
* @param {function(TYPE): TYPE} mutate
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
* @template TYPE
*/
function wrapWait(wait, mutate) {
Expand Down
12 changes: 6 additions & 6 deletions build-system/tasks/e2e/describes-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function getConfig() {
/**
* Configure and launch a Puppeteer instance
* @param {!PuppeteerConfigDef=} opt_config
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function createPuppeteer(opt_config = {}) {
const browser = await puppeteer.launch({
Expand Down Expand Up @@ -276,15 +276,15 @@ class ItConfig {
* that also sets up the provided fixtures and returns the corresponding
* environment objects of each fixture to the test method.
* @param {function(!Object):!Array<?Fixture>} factory
* @return {*} TODO(#23582): Specify return type
* @return {function()}
*/
function describeEnv(factory) {
/**
* @param {string} suiteName
* @param {!Object} spec
* @param {function(!Object)} fn
* @param {function(string, function())} describeFunc
* @return {*} TODO(#23582): Specify return type
* @return {function()}
*/
const templateFunc = function(suiteName, spec, fn, describeFunc) {
const fixture = factory(spec);
Expand Down Expand Up @@ -390,7 +390,7 @@ function describeEnv(factory) {
* @param {string} name
* @param {!Object} spec
* @param {function(!Object)} fn
* @return {*} TODO(#23582): Specify return type
* @return {function()}
*/
const mainFunc = function(name, spec, fn) {
return templateFunc(name, spec, fn, describe);
Expand All @@ -400,7 +400,7 @@ function describeEnv(factory) {
* @param {string} name
* @param {!Object} spec
* @param {function(!Object)} fn
* @return {*} TODO(#23582): Specify return type
* @return {function()}
*/
mainFunc.only = function(name, spec, fn) {
return templateFunc(name, spec, fn, describe./*OK*/ only);
Expand Down Expand Up @@ -459,7 +459,7 @@ class EndToEndFixture {
* Get the controller object for the configured engine.
* @param {!DescribesConfigDef} describesConfig
* @param {string} browserName
* @return {*} TODO(#23582): Specify return type
* @return {!SeleniumWebDriverController}
*/
async function getController(
{engine = 'selenium', headless = false},
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/e2e/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function installRepl(global, env) {
/**
* Usage: in a test, await repl();
* @param {*} mochaThis
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
global.repl = function(mochaThis) {
mochaThis.timeout(REPL_INFINITE_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/extension-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function buildExtension(
* @param {string} name
* @param {string} version
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildExtensionCss(path, name, version, options) {
/**
Expand Down
3 changes: 1 addition & 2 deletions build-system/tasks/generate-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ function writeGeneratedAtCommitFile(runnerJarDir) {
* Generates the custom closure compiler binary (runner.jar) and drops it in the
* given subdirectory of build-system/runner/dist/ (to enable concurrent usage)
* @param {string} subDir
*
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function generateRunner(subDir) {
const generateCmd = `${antExecutable} -buildfile ${buildFile} -Ddist.dir dist/${subDir} jar`;
Expand Down
12 changes: 6 additions & 6 deletions build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const hostname3p = argv.hostname3p || '3p.ampproject.net';

/**
* Compile all runtime targets in minified mode and drop them in dist/.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function compileAllMinifiedTargets() {
if (isTravisBuild()) {
Expand All @@ -109,7 +109,7 @@ function compileAllMinifiedTargets() {
/**
* Compile all runtime targets in unminified mode and drop them in dist/.
* @param {boolean} watch
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function compileAllUnminifiedTargets(watch) {
if (isTravisBuild()) {
Expand Down Expand Up @@ -611,7 +611,7 @@ function printNobuildHelp() {
* Enables runtime to be used for local testing by writing AMP_CONFIG to file.
* Called at the end of "gulp build" and "gulp dist --fortesting".
* @param {string} targetFile File to which the config is to be written.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function enableLocalTesting(targetFile) {
const config = argv.config === 'canary' ? 'canary' : 'prod';
Expand Down Expand Up @@ -698,7 +698,7 @@ function thirdPartyBootstrap(input, outputName, shouldMinify) {
* Build ALP JS.
*
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildAlp(options) {
options = options || {};
Expand All @@ -715,7 +715,7 @@ function buildAlp(options) {
* Build Examiner JS.
*
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildExaminer(options) {
return compileJs('./src/examiner/', 'examiner.js', './dist/', {
Expand All @@ -731,7 +731,7 @@ function buildExaminer(options) {
* Build web worker JS.
*
* @param {!Object} options
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
function buildWebWorker(options) {
return compileJs('./src/web-worker/', 'web-worker.js', './dist/', {
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/json-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const expectedCaches = ['cloudflare', 'google'];

/**
* Fail if caches.json is missing some expected caches.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function cachesJson() {
return gulp.src(['caches.json']).pipe(
Expand Down Expand Up @@ -61,7 +61,7 @@ async function cachesJson() {

/**
* Fail if JSON files are valid.
* @return {*} TODO(#23582): Specify return type
* @return {!Promise}
*/
async function jsonSyntax() {
let hasError = false;
Expand Down
3 changes: 1 addition & 2 deletions build-system/tasks/nailgun.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ const NAILGUN_STARTUP_TIMEOUT_MS = 5 * 1000;

/**
* Replaces the default compiler binary with nailgun on linux and macos
* @return {*} TODO(#23582): Specify return type
* @return {?NodeRequire}
*/
function maybeReplaceDefaultCompiler() {
if (process.platform == 'darwin') {
return require('require-hijack')
.replace('google-closure-compiler-osx')
.with(nailgunRunner);
return true;
} else if (process.platform == 'linux') {
return require('require-hijack')
.replace('google-closure-compiler-linux')
Expand Down
Loading

0 comments on commit cc4c6a6

Please sign in to comment.