Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release-4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser authored Oct 31, 2021
2 parents 787bb76 + bf6d164 commit 4113279
Show file tree
Hide file tree
Showing 505 changed files with 13,339 additions and 2,411 deletions.
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions scripts/build/findUpDir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { join, resolve, dirname } = require("path");
const { existsSync } = require("fs");

// search directories upward to avoid hard-wired paths based on the
// build tree (same as src/harness/findUpDir.ts)

function findUpFile(name) {
let dir = __dirname;
while (true) {
const fullPath = join(dir, name);
if (existsSync(fullPath)) return fullPath;
const up = resolve(dir, "..");
if (up === dir) return name; // it'll fail anyway
dir = up;
}
}
exports.findUpFile = findUpFile;

const findUpRoot = () =>
findUpRoot.cached || (findUpRoot.cached = dirname(findUpFile("Gulpfile.js")));
exports.findUpRoot = findUpRoot;
14 changes: 11 additions & 3 deletions scripts/build/projects.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
const { exec, Debouncer } = require("./utils");
const { resolve } = require("path");
const { findUpRoot } = require("./findUpDir");

class ProjectQueue {
/**
Expand Down Expand Up @@ -33,7 +35,13 @@ class ProjectQueue {
}
}

const projectBuilder = new ProjectQueue((projects, lkg, force) => exec(process.execPath, [lkg ? "./lib/tsc" : "./built/local/tsc", "-b", ...(force ? ["--force"] : []), ...projects], { hidePrompt: true }));
const execTsc = (lkg, ...args) =>
exec(process.execPath,
[resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"),
"-b", ...args],
{ hidePrompt: true })

const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects));

/**
* @param {string} project
Expand All @@ -43,14 +51,14 @@ const projectBuilder = new ProjectQueue((projects, lkg, force) => exec(process.e
*/
exports.buildProject = (project, { lkg, force } = {}) => projectBuilder.enqueue(project, { lkg, force });

const projectCleaner = new ProjectQueue((projects, lkg) => exec(process.execPath, [lkg ? "./lib/tsc" : "./built/local/tsc", "-b", "--clean", ...projects], { hidePrompt: true }));
const projectCleaner = new ProjectQueue((projects, lkg) => execTsc(lkg, "--clean", ...projects));

/**
* @param {string} project
*/
exports.cleanProject = (project) => projectCleaner.enqueue(project);

const projectWatcher = new ProjectQueue((projects) => exec(process.execPath, ["./lib/tsc", "-b", "--watch", ...projects], { hidePrompt: true }));
const projectWatcher = new ProjectQueue((projects) => execTsc(true, "--watch", ...projects));

/**
* @param {string} project
Expand Down
5 changes: 3 additions & 2 deletions scripts/build/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const log = require("fancy-log");
const cmdLineOptions = require("./options");
const { CancellationToken } = require("prex");
const { exec } = require("./utils");
const { findUpFile } = require("./findUpDir");

const mochaJs = require.resolve("mocha/bin/_mocha");
exports.localBaseline = "tests/baselines/local/";
Expand Down Expand Up @@ -73,11 +74,11 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
/** @type {string[]} */
let args = [];

// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
if (!runInParallel) {
args.push(mochaJs);
args.push("-R", "scripts/failed-tests");
args.push("-R", findUpFile("scripts/failed-tests.js"));
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
if (tests) {
args.push("-g", `"${tests}"`);
Expand Down
18 changes: 3 additions & 15 deletions scripts/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ const del = require("del");
const File = require("vinyl");
const ts = require("../../lib/typescript");
const chalk = require("chalk");
const which = require("which");
const { spawn } = require("child_process");
const { CancellationToken, CancelError, Deferred } = require("prex");
const { Readable, Duplex } = require("stream");

const isWindows = /^win/.test(process.platform);

/**
* Executes the provided command once with the supplied arguments.
* @param {string} cmd
Expand All @@ -32,12 +31,8 @@ function exec(cmd, args, options = {}) {
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
cancelToken.throwIfCancellationRequested();

// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
const subshellFlag = isWindows ? "/c" : "-c";
const command = isWindows ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];

if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: waitForExit ? "inherit" : "ignore", windowsVerbatimArguments: true });
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
const registration = cancelToken.register(() => {
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
proc.kill("SIGINT");
Expand Down Expand Up @@ -68,13 +63,6 @@ function exec(cmd, args, options = {}) {
}
exports.exec = exec;

/**
* @param {string} cmd
*/
function possiblyQuote(cmd) {
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
}

/**
* @param {ts.Diagnostic[]} diagnostics
* @param {{ cwd?: string, pretty?: boolean }} [options]
Expand Down Expand Up @@ -440,4 +428,4 @@ class Debouncer {
}
}
}
exports.Debouncer = Debouncer;
exports.Debouncer = Debouncer;
1 change: 1 addition & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,7 @@ namespace ts {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.ClassStaticBlockDeclaration:
// this.foo assignment in a JavaScript class
// Bind this property to the containing class
const containingClass = thisContainer.parent;
Expand Down
Loading

0 comments on commit 4113279

Please sign in to comment.