Skip to content

Commit

Permalink
reverting files which overlap with tsc
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyajones committed Mar 9, 2021
1 parent 5160d02 commit 4e788a0
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 93 deletions.
8 changes: 0 additions & 8 deletions build-system/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1740,12 +1740,4 @@ app.use('(/dist)?/rtv/*/v0/analytics-vendors/:vendor.json', (req, res) => {
});
});

// Used by test/unit/test-3p.js to test script loading.
app.use('/test/script', function (_req, res, next) {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/javascript');
res.send("typeof require === 'function' && require('foo.js');");
next();
});

module.exports = app;
4 changes: 1 addition & 3 deletions build-system/tasks/check-analytics-vendors-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ async function checkAnalyticsVendorsList() {
const anyVendorRegExp = new RegExp(blockRegExp('(.+)').source, 'gm');
while ((match = anyVendorRegExp.exec(tentative)) !== null) {
const fullMatch = match[0];
/** @type {string} */
const nameMatch = /** @type {*} */(match[2])
const name = nameMatch
const name = match[2]
.split(/[,\s]+/)
.shift()
.replace(/[`"']/g, '');
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/check-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function checkLinks() {
/**
* Reports results after all markdown files have been checked.
*
* @param {!Array<{file: string, containsDeadLinks: boolean}>} results
* @param {!Array<string>} results
*/
function reportResults(results) {
const filesWithDeadLinks = results
Expand Down Expand Up @@ -104,7 +104,7 @@ function isLinkToFileIntroducedByPR(link) {
* Checks a given markdown file for dead links.
*
* @param {string} file
* @return {!Promise<{file: string, containsDeadLinks: boolean}>}
* @return {!Promise}
*/
function checkLinksInFile(file) {
let markdown = fs.readFileSync(file).toString();
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/check-owners.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function checkOwners() {
if (!usesFilesOrLocalChanges('check-owners')) {
return;
}
const filesToCheck = getFilesToCheck(['**/OWNERS']);
const filesToCheck = getFilesToCheck('**/OWNERS');
for (const file of filesToCheck) {
await checkFile(file);
}
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/check-video-interface-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const grepJsFiles = 'extensions/**/*.js';
/**
* Returns a formatted list entry.
* @param {string} name
* @return {string}
* @return {name}
*/
const entry = (name) =>
`- [${name}](https://amp.dev/documentation/components/${name}.md)\n`;
Expand All @@ -49,7 +49,7 @@ const generateList = () =>
.trim()
.split('\n')
.reduce((list, path) => {
const name = path.substr('extensions/'.length).split('/').shift() ?? '';
const name = path.substr('extensions/'.length).split('/').shift();
return list + (excludeGeneric.includes(name) ? '' : entry(name));
}, '');

Expand Down
24 changes: 4 additions & 20 deletions build-system/tasks/dep-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const depCheckDir = '.amp-dep-check';
/**
* @typedef {{
* name: string,
* deps: ?Array<!Object<string, !ModuleDef>>
* deps: ?Array<!Object<string, !ModuleDef>
* }}
*/
let ModuleDef;
Expand All @@ -50,22 +50,6 @@ let GlobDef;
*/
let GlobsDef;

/**
* - type - Is assumed to be "forbidden" if not provided.
* - filesMatching - Is assumed to be all files if not provided.
* - mustNotDependOn - If type is "forbidden" (default) then the files
* matched must not match the glob(s) provided.
* - allowlist - Skip rule if this particular dependency is found.
* Syntax: fileAGlob->fileB where -> reads "depends on"
* @typedef {{
* type?: (string|undefined),
* filesMatching?: (string|!Array<string>|undefined),
* mustNotDependOn?: (string|!Array<string>|undefined),
* allowlist?: (string|!Array<string>|undefined),
* }}
*/
let RuleConfigDef;

/**
* @constructor @final @struct
* @param {!RuleConfigDef} config
Expand Down Expand Up @@ -171,7 +155,7 @@ const rules = depCheckConfig.rules.map((config) => new Rule(config));
* - extensions/{$extension}/{$version}/{$extension}.js
* - src/amp.js
* - 3p/integration.js
* @return {Promise<string>}
* @return {string}
*/
async function getEntryPointModule() {
const coreBinaries = ['src/amp.js', '3p/integration.js'];
Expand All @@ -193,7 +177,7 @@ async function getEntryPointModule() {

/**
* @param {string} entryPointModule
* @return {!Promise<ModuleDef>}
* @return {!ModuleDef}
*/
async function getModuleGraph(entryPointModule) {
const bundleFile = path.join(depCheckDir, 'entry-point-bundle.js');
Expand Down Expand Up @@ -243,7 +227,7 @@ function getEntryPoint(extensionFolder) {
* Flattens the module dependency graph and makes its entries unique. This
* serves as the input on which all rules are tested.
*
* @param {!ModuleDef} entryPoints
* @param {!Array<!ModuleDef>} entryPoints
* @return {!ModuleDef}
*/
function flattenGraph(entryPoints) {
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/e2e/amp-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const HOST = 'http://localhost:8000';

const EnvironmentBehaviorMap = {
[AmpdocEnvironment.SINGLE]: {
ready(_unusedController) {
ready(unusedController) {
return Promise.resolve();
},

Expand Down
6 changes: 2 additions & 4 deletions build-system/tasks/e2e/controller-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class ControllerPromise {
/**
* @param {!Promise<TYPE>|function(function(?TYPE):void, function(*):void):void} executorOrPromise
* @param {function(TYPE,function(TYPE): ?TYPE): Promise<TYPE>} opt_waitForValue
* @param {undefined|function(TYPE,function(TYPE): ?TYPE): Promise<TYPE>} opt_waitForValue
*/
constructor(executorOrPromise, opt_waitForValue) {
this.promise_ =
Expand Down Expand Up @@ -62,7 +62,6 @@ class ControllerPromise {

/** @override */
then(opt_onFulfilled, opt_onRejected) {
// opt_onFulfilled = opt_onFulfilled || ((x) => x);
// Allow this and future `then`s to update the wait value.
let wrappedWait;
if (this.waitForValue) {
Expand All @@ -82,14 +81,13 @@ class ControllerPromise {
* the inner opt_mutate function.
* @param {function(TYPE1, function(TYPE1): ?TYPE1): Promise<TYPE3>} wait
* @param {function(TYPE1): TYPE1} mutate
* @return {!function(function(TYPE1): ?TYPE1, function(TYPE1): TYPE2): Promise<TYPE3>}
* @return {function(function(TYPE1): ?TYPE1, function(TYPE1): TYPE2): Promise<TYPE3>}
* @template TYPE1
* @template TYPE2
* @template TYPE3
*/
function wrapWait(wait, mutate) {
return (condition, opt_mutate) => {
// opt_mutate = opt_mutate || ((x) => x);
return wait(condition, (value) => opt_mutate(mutate(value)));
};
}
Expand Down
10 changes: 6 additions & 4 deletions build-system/tasks/e2e/describes-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const chrome = require('selenium-webdriver/chrome');
const fetch = require('node-fetch');
const firefox = require('selenium-webdriver/firefox');
const puppeteer = require('puppeteer');
const selenium = require('selenium-webdriver');
const {
clearLastExpectError,
getLastExpectError,
Expand All @@ -31,7 +32,6 @@ const {
SeleniumWebDriverController,
} = require('./selenium-webdriver-controller');
const {AmpDriver, AmpdocEnvironment} = require('./amp-driver');
const selenium = require('selenium-webdriver');
const {HOST, PORT} = require('../serve');
const {installRepl, uninstallRepl} = require('./repl');
const {isCiBuild} = require('../../common/ci');
Expand Down Expand Up @@ -424,7 +424,7 @@ function describeEnv(factory) {
* @param {!Object} spec
* @param {function(!Object): void} fn
* @param {function(string, function(): void): void} describeFunc
* @return {void}
*/
const templateFunc = function (suiteName, spec, fn, describeFunc) {
const fixture = factory(spec);
Expand Down Expand Up @@ -506,9 +506,10 @@ function describeEnv(factory) {
}
}

return describeFunc(suiteName, function () {
describeFunc(suiteName, function () {
createBrowserDescribe();
});
return;

/**
*
Expand Down Expand Up @@ -601,7 +602,8 @@ function describeEnv(factory) {
* @param {function(!Object): void} fn
*/
mainFunc.only = function (name, spec, fn) {
templateFunc(name, spec, fn, describe.only);
templateFunc(name, spec, fn, describe./*OK*/ only);
return;
};

/**
Expand Down
24 changes: 12 additions & 12 deletions build-system/tasks/e2e/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck

const chai = require('chai');
chai.use(require('chai-as-promised'));
Expand All @@ -40,7 +39,7 @@ function getLastExpectError() {
/**
* @param {*} actual
* @param {string=} opt_message
* @return {!chai.ExpectStatic}
* @return {!ExpectStatic}
*/
function expect(actual, opt_message) {
if (!installed) {
Expand Down Expand Up @@ -140,8 +139,8 @@ const chaiMethodsAndProperties = [
];

/**
* @param {chai.ChaiStatic} chai
* @param {chai.ChaiUtils} utils
* @param {Chai.ChaiStatic} chai
* @param {Chai.ChaiUtils} utils
* @return {void}
*/
function installWrappers(chai, utils) {
Expand Down Expand Up @@ -174,8 +173,8 @@ function installWrappers(chai, utils) {
}

/**
* @param {chai.ChaiUtils} utils
* @return {function(_super: chai.AssertionStatic): function(): any}
* @param {Chai.ChaiUtils} utils
* @return {Function(_super: Chai.AssertionStatic): Function(): any}
*/
function overwriteAlwaysUseSuper(utils) {
const {flag} = utils;
Expand Down Expand Up @@ -233,8 +232,8 @@ function overwriteAlwaysUseSuper(utils) {
}

/**
* @param {chai.AssertionStatic} _super
* @return {function(): *}
* @param {Chai.AssertionStatic} _super
* @return {Function(): *}
*/
function inheritChainingBehavior(_super) {
return function () {
Expand All @@ -243,8 +242,8 @@ function inheritChainingBehavior(_super) {
}

/**
* @param {chai.AssertionStatic} _super
* @return {function(): *}
* @param {Chai.AssertionStatic} _super
* @return {Function(): *}
*/
function overwriteUnsupported(_super) {
return function () {
Expand All @@ -269,8 +268,9 @@ function installBrowserAssertions(_networkLogger) {
}

/**
* @param {chai.ChaiStatic} chai
* @param {chai.ChaiUtils} utils
*
* @param {Chai.ChaiStatic} chai
* @param {Chai.ChaiUtils} utils
* @return {void}
*/
function installBrowserWrappers(chai, utils) {
Expand Down
1 change: 0 additions & 1 deletion build-system/tasks/e2e/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck

require('babel-regenerator-runtime');
const describes = require('./describes-e2e');
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/e2e/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function fetchCoverage_(outDir) {
response.pipe(zipFile);
zipFile.on('finish', () => {
zipFile.close();
resolve(undefined);
resolve();
});
}
)
Expand Down
8 changes: 5 additions & 3 deletions build-system/tasks/e2e/network-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {logging, WebDriver} from 'selenium-webdriver';
import selenium from 'selenium-webdriver';

const {logging} = selenium;

/** @enum {string} */
const PerformanceMethods = {
Expand All @@ -27,9 +29,9 @@ const PerformanceMethods = {
};

export class NetworkLogger {
/** @param {!WebDriver} driver */
/** @param {!selenium.WebDriver} driver */
constructor(driver) {
/** @type {WebDriver} */
/** @type {selenium.WebDriver} */
this.driver_ = driver;
}

Expand Down
1 change: 0 additions & 1 deletion build-system/tasks/e2e/puppeteer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck

const fs = require('fs');
const puppeteer = require('puppeteer');
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/e2e/selenium-webdriver-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// @ts-nocheck

const fs = require('fs');
const selenium = require('selenium-webdriver');
const {
DOMRectDef,
ElementHandle,
Key,
} = require('./functional-test-controller');
const selenium = require('selenium-webdriver');
const {ControllerPromise} = require('./controller-promise');
const {expect} = require('chai');
const {NetworkLogger} = require('./network-logger');
Expand Down Expand Up @@ -681,7 +681,7 @@ class SeleniumWebDriverController {

/**.
* @param {!ElementHandle<!selenium.WebElement>} handle
* @param {!function(): any} getter
* @param {function(): any} getter
* @return {!Promise<void>}
*/
async switchToShadowInternal_(handle, getter) {
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {log} = require('../common/logging');

/**
* @param {string} dest
* @return {Promise<string[]>}
* @return {string[]}
*/
async function walk(dest) {
const filelist = [];
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/prettify.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function prettify() {
/**
* Resolves the prettier config for the given file
* @param {string} file
* @return {Promise<Object>}
* @return {Object}
*/
async function getOptions(file) {
const config = await prettier.resolveConfig(file);
Expand Down
Loading

0 comments on commit 4e788a0

Please sign in to comment.