Skip to content

Commit

Permalink
🏗 ♻️ Fix type errors in /build-system/tasks (#33074)
Browse files Browse the repository at this point in the history
* fix around 300 type errors in /build-system/tasks

* add error messages as per suggestion

* change file read format in print-report

* remove empty comments. I will add better JSDoc prior to enabling enforcement

Co-authored-by: Raghu Simha <rsimha@amp.dev>
  • Loading branch information
rileyajones and rsimha committed Mar 17, 2021
1 parent 948ddf5 commit f6c1dde
Show file tree
Hide file tree
Showing 70 changed files with 160 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function () {

/**
* @param {BabelPath} path
* @return {void}
* @return {BabelPath|void}
*/
function deepestMember(path) {
while (true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module.exports = function ({types: t}) {
/**
* @param {CompilerNode} leftPath
* @param {CompilerNode} rightPath
* @return {void}
*/
function joinTemplateLiterals(leftPath, rightPath) {
const {node: leftNode} = leftPath;
Expand All @@ -59,7 +58,6 @@ module.exports = function ({types: t}) {

/**
* @param {BabelPath} path
* @return {void}
*/
function joinMaybeTemplateLiteral(path) {
const left = path.get('left');
Expand Down Expand Up @@ -111,7 +109,6 @@ module.exports = function ({types: t}) {

/**
* @param {BabelPath} path
* @return {void}
*/
TemplateLiteral(path) {
// Convert any items inside a template literal that are static literals.
Expand Down
19 changes: 4 additions & 15 deletions build-system/compile/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,23 @@ let OptionsDef;
* production use. During development we intend to continue using
* babel, as it has much faster incremental compilation.
*
* @param {string} entryModuleFilename
* @param {string|string[]} entryModuleFilename
* @param {string} outputDir
* @param {string} outputFilename
* @param {!OptionsDef} options
* @param {{startTime?: number}} timeInfo
* @param {{startTime?: number}=} timeInfo
* @return {Promise<void>}
*/
async function closureCompile(
entryModuleFilename,
outputDir,
outputFilename,
options,
timeInfo
timeInfo = {}
) {
// Rate limit closure compilation to MAX_PARALLEL_CLOSURE_INVOCATIONS
// concurrent processes.
return new Promise(function (resolve, reject) {
/**
* @return {void}
*/
function start() {
inProgress++;
compile(
Expand All @@ -95,9 +92,7 @@ async function closureCompile(
(reason) => reject(reason)
);
}
/**
* @return {void}
*/

function next() {
if (!queue.length) {
return;
Expand All @@ -111,9 +106,6 @@ async function closureCompile(
});
}

/**
* @return {void}
*/
function cleanupBuildDir() {
del.sync('build/fake-module');
del.sync('build/patched-module');
Expand Down Expand Up @@ -455,9 +447,6 @@ async function compile(
}
}

/**
* @return {void}
*/
function printClosureConcurrency() {
log(
green('Using up to'),
Expand Down
5 changes: 2 additions & 3 deletions build-system/compile/debug-compilation-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const LIFECYCLES = {
*
* @param {string} lifecycle
* @param {string} fullpath
* @param {Buffer} content
* @param {Object} sourcemap
* @param {string=} content
* @param {Object=} sourcemap
*/
function debug(lifecycle, fullpath, content, sourcemap) {
if (argv.debug && Object.keys(LIFECYCLES).includes(lifecycle)) {
Expand Down Expand Up @@ -72,7 +72,6 @@ function debug(lifecycle, fullpath, content, sourcemap) {

/**
* Logs debug information.
* @return {void}
*/
function displayLifecycleDebugging() {
if (argv.debug) {
Expand Down
1 change: 0 additions & 1 deletion build-system/eslint-rules/dict-string-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ module.exports = function (context) {
/**
* @param {*} node
* @param {*} context
* @return {void}
*/
function checkNode(node, context) {
if (node.type === 'ObjectExpression') {
Expand Down
6 changes: 2 additions & 4 deletions build-system/eslint-rules/html-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const {
module.exports = function (context) {
/**
* @param {CompilerNode} node
* @return {void}
*/
function tagCannotBeCalled(node) {
const {name} = node.callee;
Expand All @@ -47,7 +46,6 @@ module.exports = function (context) {

/**
* @param {CompilerNode} node
* @return {void}
*/
function factoryUsage(node) {
const {parent} = node;
Expand All @@ -56,7 +54,8 @@ module.exports = function (context) {
const expectedTagName = staticTemplateFactories[name];

if (parent.type === 'TaggedTemplateExpression' && parent.tag === node) {
return tagUsage(parent, `${name}()`);
tagUsage(parent, `${name}()`);
return;
}

if (
Expand Down Expand Up @@ -89,7 +88,6 @@ module.exports = function (context) {
/**
* @param {CompilerNode} node
* @param {string} opt_name
* @return {void}
*/
function tagUsage(node, opt_name) {
const {quasi, tag} = node;
Expand Down
1 change: 0 additions & 1 deletion build-system/eslint-rules/no-import-rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module.exports = function (context) {
* @param {*} node
* @param {string} modulePath
* @param {*} mods
* @return {void}
*/
function ImportSpecifier(node, modulePath, mods) {
const {imported, local} = node;
Expand Down
1 change: 0 additions & 1 deletion build-system/eslint-rules/preact.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module.exports = {
create(context) {
/**
* @param {*} node
* @return {void}
*/
function requirePreact(node) {
if (imported) {
Expand Down
4 changes: 0 additions & 4 deletions build-system/eslint-rules/prefer-destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ module.exports = {

/**
* @param {Map[]} maps
* @return {void}
*/
function processMaps(maps) {
for (let i = 0; i < maps.length; i++) {
Expand All @@ -111,7 +110,6 @@ module.exports = {
/**
* @param {*} struct
* @param {*} base
* @return {void}
*/
function processVariables(struct, base) {
const {names, nodes, declarations, node} = struct;
Expand Down Expand Up @@ -153,7 +151,6 @@ module.exports = {
return {
/**
* @param {CompilerNode} node
* @return {void}
*/
VariableDeclarator(node) {
if (!shouldBeDestructure(node)) {
Expand All @@ -180,7 +177,6 @@ module.exports = {

/**
* @param {CompilerNode} node
* @return {void}
*/
'BlockStatement, Program': function (node) {
const {body} = node;
Expand Down
8 changes: 4 additions & 4 deletions build-system/eslint-rules/query-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const cssWhat = require('css-what');
module.exports = function (context) {
/**
* @param {CompilerNode} node
* @return {void}
*/
function callQuerySelector(node) {
const {callee} = node;
Expand All @@ -45,10 +44,11 @@ module.exports = function (context) {
const selector = getSelector(node, 0);

if (!isValidSelector(selector)) {
return context.report({
context.report({
node,
message: 'Failed to parse CSS Selector `' + selector + '`',
});
return;
}

// What are we calling querySelector on?
Expand Down Expand Up @@ -84,7 +84,6 @@ module.exports = function (context) {

/**
* @param {CompilerNode} node
* @return {void}
*/
function callScopedQuerySelector(node) {
const {callee} = node;
Expand All @@ -103,10 +102,11 @@ module.exports = function (context) {
const selector = getSelector(node, 1);

if (!isValidSelector(selector)) {
return context.report({
context.report({
node,
message: 'Failed to parse CSS Selector `' + selector + '`',
});
return;
}

if (selectorNeedsScope(selector)) {
Expand Down
3 changes: 0 additions & 3 deletions build-system/eslint-rules/unused-private-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module.exports = {
* @param {CompilerNode} node
* @param {string} name
* @param {boolean} used
* @return {void}
*/
function restrictedUse(node, name, used) {
if (used) {
Expand Down Expand Up @@ -135,7 +134,6 @@ module.exports = {
* @param {CompilerNode} node
* @param {string} name
* @param {boolean} used
* @return {void}
*/
function visibleForTestingUse(node, name, used) {
if (!used) {
Expand Down Expand Up @@ -163,7 +161,6 @@ module.exports = {
* @param {CompilerNode} node
* @param {string} name
* @param {boolean} used
* @return {void}
*/
function unannotatedUse(node, name, used) {
if (used) {
Expand Down
6 changes: 0 additions & 6 deletions build-system/pr-check/bundle-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ const {runCiJob} = require('./ci-job');

const jobName = 'bundle-size.js';

/**
* @return {void}
*/
function pushBuildWorkflow() {
downloadNomoduleOutput();
downloadModuleOutput();
timedExecOrDie('gulp bundle-size --on_push_build');
}

/**
* @return {void}
*/
function prBuildWorkflow() {
if (buildTargetsInclude(Targets.RUNTIME)) {
downloadNomoduleOutput();
Expand Down
3 changes: 0 additions & 3 deletions build-system/pr-check/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const {timedExecOrDie} = require('./utils');

const jobName = 'checks.js';

/**
* @return {void}
*/
function pushBuildWorkflow() {
timedExecOrDie('gulp presubmit');
timedExecOrDie('gulp lint');
Expand Down
3 changes: 0 additions & 3 deletions build-system/pr-check/cross-browser-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ function runUnitTestsForPlatform() {
}
}

/**
* @return {void}
*/
function pushBuildWorkflow() {
runUnitTestsForPlatform();
timedExecOrDie('gulp dist --fortesting');
Expand Down
6 changes: 0 additions & 6 deletions build-system/pr-check/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const {runCiJob} = require('./ci-job');

const jobName = 'e2e-tests.js';

/**
* @return {void}
*/
function pushBuildWorkflow() {
downloadNomoduleOutput();
try {
Expand All @@ -49,9 +46,6 @@ function pushBuildWorkflow() {
}
}

/**
* @return {void}
*/
function prBuildWorkflow() {
if (buildTargetsInclude(Targets.RUNTIME, Targets.E2E_TEST)) {
downloadNomoduleOutput();
Expand Down
6 changes: 0 additions & 6 deletions build-system/pr-check/experiment-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const {runCiJob} = require('./ci-job');

const jobName = `${experiment}-build.js`;

/**
* @return {void}
*/
function pushBuildWorkflow() {
const config = getExperimentConfig(experiment);
if (config) {
Expand All @@ -48,9 +45,6 @@ function pushBuildWorkflow() {
}
}

/**
* @return {void}
*/
function prBuildWorkflow() {
if (
buildTargetsInclude(
Expand Down
6 changes: 0 additions & 6 deletions build-system/pr-check/experiment-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const {runCiJob} = require('./ci-job');

const jobName = `${experiment}-tests.js`;

/**
* @return {void}
*/
function pushBuildWorkflow() {
const config = getExperimentConfig(experiment);
if (config) {
Expand All @@ -54,9 +51,6 @@ function pushBuildWorkflow() {
}
}

/**
* @return {void}
*/
function prBuildWorkflow() {
if (
buildTargetsInclude(
Expand Down
6 changes: 0 additions & 6 deletions build-system/pr-check/module-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ const {runCiJob} = require('./ci-job');

const jobName = 'module-build.js';

/**
* @return {void}
*/
function pushBuildWorkflow() {
timedExecOrDie('gulp dist --esm --fortesting');
uploadModuleOutput();
}

/**
* @return {void}
*/
function prBuildWorkflow() {
// TODO(#31102): This list must eventually match the same buildTargets check
// found in pr-check/nomodule-build.js as we turn on the systems that
Expand Down

0 comments on commit f6c1dde

Please sign in to comment.