Skip to content

Commit f28a433

Browse files
committed
Merge remote-tracking branch 'upstream/main' into es2022
2 parents c940acb + f424dfc commit f28a433

File tree

313 files changed

+6644
-1347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+6644
-1347
lines changed

Diff for: package-lock.json

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: scripts/build/findUpDir.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { join, resolve, dirname } = require("path");
2+
const { existsSync } = require("fs");
3+
4+
// search directories upward to avoid hard-wired paths based on the
5+
// build tree (same as src/harness/findUpDir.ts)
6+
7+
function findUpFile(name) {
8+
let dir = __dirname;
9+
while (true) {
10+
const fullPath = join(dir, name);
11+
if (existsSync(fullPath)) return fullPath;
12+
const up = resolve(dir, "..");
13+
if (up === dir) return name; // it'll fail anyway
14+
dir = up;
15+
}
16+
}
17+
exports.findUpFile = findUpFile;
18+
19+
const findUpRoot = () =>
20+
findUpRoot.cached || (findUpRoot.cached = dirname(findUpFile("Gulpfile.js")));
21+
exports.findUpRoot = findUpRoot;

Diff for: scripts/build/projects.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22
const { exec, Debouncer } = require("./utils");
3+
const { resolve } = require("path");
4+
const { findUpRoot } = require("./findUpDir");
35

46
class ProjectQueue {
57
/**
@@ -33,7 +35,13 @@ class ProjectQueue {
3335
}
3436
}
3537

36-
const projectBuilder = new ProjectQueue((projects, lkg, force) => exec(process.execPath, [lkg ? "./lib/tsc" : "./built/local/tsc", "-b", ...(force ? ["--force"] : []), ...projects], { hidePrompt: true }));
38+
const execTsc = (lkg, ...args) =>
39+
exec(process.execPath,
40+
[resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"),
41+
"-b", ...args],
42+
{ hidePrompt: true })
43+
44+
const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects));
3745

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

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

4856
/**
4957
* @param {string} project
5058
*/
5159
exports.cleanProject = (project) => projectCleaner.enqueue(project);
5260

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

5563
/**
5664
* @param {string} project

Diff for: scripts/build/tests.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const log = require("fancy-log");
99
const cmdLineOptions = require("./options");
1010
const { CancellationToken } = require("prex");
1111
const { exec } = require("./utils");
12+
const { findUpFile } = require("./findUpDir");
1213

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

76-
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
77+
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
7778
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
7879
if (!runInParallel) {
7980
args.push(mochaJs);
80-
args.push("-R", "scripts/failed-tests");
81+
args.push("-R", findUpFile("scripts/failed-tests.js"));
8182
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
8283
if (tests) {
8384
args.push("-g", `"${tests}"`);

Diff for: scripts/build/utils.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ const del = require("del");
99
const File = require("vinyl");
1010
const ts = require("../../lib/typescript");
1111
const chalk = require("chalk");
12+
const which = require("which");
1213
const { spawn } = require("child_process");
1314
const { CancellationToken, CancelError, Deferred } = require("prex");
1415
const { Readable, Duplex } = require("stream");
1516

16-
const isWindows = /^win/.test(process.platform);
17-
1817
/**
1918
* Executes the provided command once with the supplied arguments.
2019
* @param {string} cmd
@@ -32,12 +31,8 @@ function exec(cmd, args, options = {}) {
3231
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
3332
cancelToken.throwIfCancellationRequested();
3433

35-
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
36-
const subshellFlag = isWindows ? "/c" : "-c";
37-
const command = isWindows ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
38-
3934
if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
40-
const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: waitForExit ? "inherit" : "ignore", windowsVerbatimArguments: true });
35+
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
4136
const registration = cancelToken.register(() => {
4237
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
4338
proc.kill("SIGINT");
@@ -68,13 +63,6 @@ function exec(cmd, args, options = {}) {
6863
}
6964
exports.exec = exec;
7065

71-
/**
72-
* @param {string} cmd
73-
*/
74-
function possiblyQuote(cmd) {
75-
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
76-
}
77-
7866
/**
7967
* @param {ts.Diagnostic[]} diagnostics
8068
* @param {{ cwd?: string, pretty?: boolean }} [options]
@@ -440,4 +428,4 @@ class Debouncer {
440428
}
441429
}
442430
}
443-
exports.Debouncer = Debouncer;
431+
exports.Debouncer = Debouncer;

Diff for: src/compiler/binder.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,7 @@ namespace ts {
29472947
case SyntaxKind.MethodDeclaration:
29482948
case SyntaxKind.GetAccessor:
29492949
case SyntaxKind.SetAccessor:
2950+
case SyntaxKind.ClassStaticBlockDeclaration:
29502951
// this.foo assignment in a JavaScript class
29512952
// Bind this property to the containing class
29522953
const containingClass = thisContainer.parent;

0 commit comments

Comments
 (0)