Skip to content

Commit 3505ba7

Browse files
committed
[generated] Run dprint and update baselines
[git-generate] set -x npm ci npx dprint fmt npx hereby clean npx hereby dts npx hereby runtests -t 'Public APIs|goToTypeDefinition_' &> /dev/null || npx hereby baseline-accept
1 parent e94a380 commit 3505ba7

File tree

439 files changed

+87581
-23222
lines changed

Some content is hidden

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

439 files changed

+87581
-23222
lines changed

Herebyfile.mjs

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ const localize = task({
131131
dependencies: [generateDiagnostics],
132132
run: async () => {
133133
if (needsUpdate(diagnosticMessagesGeneratedJson, generatedLCGFile)) {
134-
await exec(process.execPath, ["scripts/generateLocalizedDiagnosticMessages.mjs", "src/loc/lcl", "built/local", diagnosticMessagesGeneratedJson], { ignoreExitCode: true });
134+
await exec(process.execPath, [
135+
"scripts/generateLocalizedDiagnosticMessages.mjs",
136+
"src/loc/lcl",
137+
"built/local",
138+
diagnosticMessagesGeneratedJson,
139+
], { ignoreExitCode: true });
135140
}
136141
},
137142
});
@@ -312,7 +317,10 @@ function entrypointBuildTask(options) {
312317
const outDir = path.dirname(options.output);
313318
await fs.promises.mkdir(outDir, { recursive: true });
314319
const moduleSpecifier = path.relative(outDir, options.builtEntrypoint);
315-
await fs.promises.writeFile(options.output, `module.exports = require("./${moduleSpecifier.replace(/[\\/]/g, "/")}")`);
320+
await fs.promises.writeFile(
321+
options.output,
322+
`module.exports = require("./${moduleSpecifier.replace(/[\\/]/g, "/")}")`,
323+
);
316324
},
317325
});
318326

@@ -336,13 +344,19 @@ function entrypointBuildTask(options) {
336344
const watch = task({
337345
name: `watch-${options.name}`,
338346
hiddenFromTaskList: true, // This is best effort.
339-
dependencies: (options.buildDeps ?? []).concat(options.mainDeps ?? []).concat(cmdLineOptions.bundle ? [] : [shim]),
347+
dependencies: (options.buildDeps ?? []).concat(options.mainDeps ?? []).concat(
348+
cmdLineOptions.bundle ? [] : [shim],
349+
),
340350
run: () => {
341351
// These watch functions return promises that resolve once watch mode has started,
342352
// allowing them to operate as regular tasks, while creating unresolved promises
343353
// in the background that keep the process running after all tasks have exited.
344354
if (!printedWatchWarning) {
345-
console.error(chalk.yellowBright("Warning: watch mode is incomplete and may not work as expected. Use at your own risk."));
355+
console.error(
356+
chalk.yellowBright(
357+
"Warning: watch mode is incomplete and may not work as expected. Use at your own risk.",
358+
),
359+
);
346360
printedWatchWarning = true;
347361
}
348362

@@ -386,7 +400,12 @@ export const dtsServices = task({
386400
description: "Bundles typescript.d.ts",
387401
dependencies: [buildServices],
388402
run: async () => {
389-
if (needsUpdate("./built/local/typescript/tsconfig.tsbuildinfo", ["./built/local/typescript.d.ts", "./built/local/typescript.internal.d.ts"])) {
403+
if (
404+
needsUpdate("./built/local/typescript/tsconfig.tsbuildinfo", [
405+
"./built/local/typescript.d.ts",
406+
"./built/local/typescript.internal.d.ts",
407+
])
408+
) {
390409
await runDtsBundler("./built/local/typescript/typescript.d.ts", "./built/local/typescript.d.ts");
391410
}
392411
},
@@ -435,8 +454,16 @@ export const dtsLssl = task({
435454
description: "Bundles tsserverlibrary.d.ts",
436455
dependencies: [buildLssl],
437456
run: async () => {
438-
if (needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", ["./built/local/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.internal.d.ts"])) {
439-
await runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts");
457+
if (
458+
needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", [
459+
"./built/local/tsserverlibrary.d.ts",
460+
"./built/local/tsserverlibrary.internal.d.ts",
461+
])
462+
) {
463+
await runDtsBundler(
464+
"./built/local/tsserverlibrary/tsserverlibrary.d.ts",
465+
"./built/local/tsserverlibrary.d.ts",
466+
);
440467
}
441468
},
442469
});
@@ -572,7 +599,13 @@ export const watchOtherOutputs = task({
572599
name: "watch-other-outputs",
573600
description: "Builds miscelaneous scripts and documents distributed with the LKG",
574601
hiddenFromTaskList: true,
575-
dependencies: [watchCancellationToken, watchTypingsInstaller, watchWatchGuard, generateTypesMap, copyBuiltLocalDiagnosticMessages],
602+
dependencies: [
603+
watchCancellationToken,
604+
watchTypingsInstaller,
605+
watchWatchGuard,
606+
generateTypesMap,
607+
copyBuiltLocalDiagnosticMessages,
608+
],
576609
});
577610

578611
export const local = task({
@@ -650,7 +683,10 @@ export const runTestsAndWatch = task({
650683
if (!token.signaled) {
651684
running = true;
652685
try {
653-
await runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, { token, watching: true });
686+
await runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, {
687+
token,
688+
watching: true,
689+
});
654690
}
655691
catch {
656692
// ignore
@@ -805,7 +841,10 @@ export const updateSublime = task({
805841
dependencies: [tsserver],
806842
run: async () => {
807843
for (const file of ["built/local/tsserver.js", "built/local/tsserver.js.map"]) {
808-
await fs.promises.copyFile(file, path.resolve("../TypeScript-Sublime-Plugin/tsserver/", path.basename(file)));
844+
await fs.promises.copyFile(
845+
file,
846+
path.resolve("../TypeScript-Sublime-Plugin/tsserver/", path.basename(file)),
847+
);
809848
}
810849
},
811850
});
@@ -834,7 +873,10 @@ export const produceLKG = task({
834873
.concat(localizationTargets)
835874
.filter(f => !fs.existsSync(f));
836875
if (missingFiles.length > 0) {
837-
throw new Error("Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles.join("\n"));
876+
throw new Error(
877+
"Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n"
878+
+ missingFiles.join("\n"),
879+
);
838880
}
839881

840882
await exec(process.execPath, ["scripts/produceLKG.mjs"]);
@@ -862,19 +904,37 @@ export const clean = task({
862904
export const configureNightly = task({
863905
name: "configure-nightly",
864906
description: "Runs scripts/configurePrerelease.mjs to prepare a build for nightly publishing",
865-
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "dev", "package.json", "src/compiler/corePublic.ts"]),
907+
run: () =>
908+
exec(process.execPath, [
909+
"scripts/configurePrerelease.mjs",
910+
"dev",
911+
"package.json",
912+
"src/compiler/corePublic.ts",
913+
]),
866914
});
867915

868916
export const configureInsiders = task({
869917
name: "configure-insiders",
870918
description: "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing",
871-
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "insiders", "package.json", "src/compiler/corePublic.ts"]),
919+
run: () =>
920+
exec(process.execPath, [
921+
"scripts/configurePrerelease.mjs",
922+
"insiders",
923+
"package.json",
924+
"src/compiler/corePublic.ts",
925+
]),
872926
});
873927

874928
export const configureExperimental = task({
875929
name: "configure-experimental",
876930
description: "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing",
877-
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "experimental", "package.json", "src/compiler/corePublic.ts"]),
931+
run: () =>
932+
exec(process.execPath, [
933+
"scripts/configurePrerelease.mjs",
934+
"experimental",
935+
"package.json",
936+
"src/compiler/corePublic.ts",
937+
]),
878938
});
879939

880940
export const help = task({

scripts/build/localization.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
export const localizationDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"].map(f => f.toLowerCase());
1+
export const localizationDirectories = [
2+
"cs",
3+
"de",
4+
"es",
5+
"fr",
6+
"it",
7+
"ja",
8+
"ko",
9+
"pl",
10+
"pt-br",
11+
"ru",
12+
"tr",
13+
"zh-cn",
14+
"zh-tw",
15+
].map(f => f.toLowerCase());

scripts/build/options.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@ import os from "os";
44
const ci = ["1", "true"].includes(process.env.CI ?? "");
55

66
const parsed = minimist(process.argv.slice(2), {
7-
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage"],
7+
boolean: [
8+
"dirty",
9+
"light",
10+
"colors",
11+
"lkg",
12+
"soft",
13+
"fix",
14+
"failed",
15+
"keepFailed",
16+
"force",
17+
"built",
18+
"ci",
19+
"bundle",
20+
"typecheck",
21+
"lint",
22+
"coverage",
23+
],
824
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
925
alias: {
1026
/* eslint-disable quote-props */

scripts/build/projects.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ class ProjectQueue {
3939

4040
const tscPath = resolve(
4141
findUpRoot(),
42-
cmdLineOptions.lkg ? "./lib/tsc.js" :
43-
cmdLineOptions.built ? "./built/local/tsc.js" :
44-
"./node_modules/typescript/lib/tsc.js",
42+
cmdLineOptions.lkg ? "./lib/tsc.js"
43+
: cmdLineOptions.built ? "./built/local/tsc.js"
44+
: "./node_modules/typescript/lib/tsc.js",
4545
);
4646

47-
const execTsc = (/** @type {string[]} */ ...args) => exec(process.execPath, [tscPath, "-b", ...args], { hidePrompt: true });
47+
const execTsc = (/** @type {string[]} */ ...args) =>
48+
exec(process.execPath, [tscPath, "-b", ...args], { hidePrompt: true });
4849

49-
const projectBuilder = new ProjectQueue(projects => execTsc(...(cmdLineOptions.bundle ? [] : ["--emitDeclarationOnly", "false"]), ...projects));
50+
const projectBuilder = new ProjectQueue(projects =>
51+
execTsc(...(cmdLineOptions.bundle ? [] : ["--emitDeclarationOnly", "false"]), ...projects)
52+
);
5053

5154
/**
5255
* @param {string} project

scripts/build/tests.mjs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
7979
}
8080

8181
if (tests || runners || light || testTimeout || taskConfigsFolder || keepFailed || shards || shardId) {
82-
writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, testTimeout, keepFailed, shards, shardId);
82+
writeTestConfigFile(
83+
tests,
84+
runners,
85+
light,
86+
taskConfigsFolder,
87+
workerCount,
88+
stackTraceLimit,
89+
testTimeout,
90+
keepFailed,
91+
shards,
92+
shardId,
93+
);
8394
}
8495

8596
const colors = cmdLineOptions.colors;
@@ -198,7 +209,18 @@ async function cleanCoverageDir() {
198209
* @param {number | undefined} [shards]
199210
* @param {number | undefined} [shardId]
200211
*/
201-
export function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed, shards, shardId) {
212+
export function writeTestConfigFile(
213+
tests,
214+
runners,
215+
light,
216+
taskConfigsFolder,
217+
workerCount,
218+
stackTraceLimit,
219+
timeout,
220+
keepFailed,
221+
shards,
222+
shardId,
223+
) {
202224
const testConfigContents = JSON.stringify({
203225
test: tests ? [tests] : undefined,
204226
runners: runners ? runners.split(",") : undefined,

scripts/build/utils.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export async function exec(cmd, args, options = {}) {
2828
const { ignoreExitCode, waitForExit = true, ignoreStdout } = options;
2929

3030
if (!options.hidePrompt) console.log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
31-
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? ignoreStdout ? ["inherit", "ignore", "inherit"] : "inherit" : "ignore" });
31+
const proc = spawn(which.sync(cmd), args, {
32+
stdio: waitForExit ? ignoreStdout ? ["inherit", "ignore", "inherit"] : "inherit" : "ignore",
33+
});
3234
if (waitForExit) {
3335
const onCanceled = () => {
3436
proc.kill();
@@ -39,8 +41,8 @@ export async function exec(cmd, args, options = {}) {
3941
resolve({ exitCode: exitCode ?? undefined });
4042
}
4143
else {
42-
const reason = options.token?.signaled ? options.token.reason ?? new CancelError() :
43-
new ExecError(exitCode);
44+
const reason = options.token?.signaled ? options.token.reason ?? new CancelError()
45+
: new ExecError(exitCode);
4446
reject(reason);
4547
}
4648
subscription?.unsubscribe();

scripts/checkPackageSize.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const baseRepo = process.argv[2];
55
const headRepo = process.argv[3];
66

77
/** @type {Array<{ size: number, unpackedSize: number; files: Array<{ path: string; size: number; }>; }>} */
8-
const [before, after] = JSON.parse(cp.execFileSync("npm", ["pack", "--dry-run", "--json", baseRepo, headRepo], { encoding: "utf8" }));
8+
const [before, after] = JSON.parse(
9+
cp.execFileSync("npm", ["pack", "--dry-run", "--json", baseRepo, headRepo], { encoding: "utf8" }),
10+
);
911

1012
/** @param {{ path: string; size: number; }[]} files */
1113
function filesToMap(files) {

scripts/configurePrerelease.mjs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ function main() {
5454
// Ensure we are actually changing something - the user probably wants to know that the update failed.
5555
if (tsFileContents === modifiedTsFileContents) {
5656
let err = `\n '${tsFilePath}' was not updated while configuring for a prerelease publish for '${tag}'.\n `;
57-
err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`;
57+
err +=
58+
`Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`;
5859
throw new Error(err + "\n");
5960
}
6061

@@ -78,19 +79,31 @@ function main() {
7879
function updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, nightlyPatch) {
7980
const majorMinorRgx = /export const versionMajorMinor = "(\d+\.\d+)"/;
8081
const majorMinorMatch = majorMinorRgx.exec(tsFileContents);
81-
assert(majorMinorMatch !== null, `The file '${tsFilePath}' seems to no longer have a string matching '${majorMinorRgx}'.`);
82+
assert(
83+
majorMinorMatch !== null,
84+
`The file '${tsFilePath}' seems to no longer have a string matching '${majorMinorRgx}'.`,
85+
);
8286
const parsedMajorMinor = majorMinorMatch[1];
83-
assert(parsedMajorMinor === majorMinor, `versionMajorMinor does not match. ${tsFilePath}: '${parsedMajorMinor}'; package.json: '${majorMinor}'`);
87+
assert(
88+
parsedMajorMinor === majorMinor,
89+
`versionMajorMinor does not match. ${tsFilePath}: '${parsedMajorMinor}'; package.json: '${majorMinor}'`,
90+
);
8491

8592
const versionRgx = /export const version(?:: string)? = `\$\{versionMajorMinor\}\.(\d)(-\w+)?`;/;
8693
const patchMatch = versionRgx.exec(tsFileContents);
87-
assert(patchMatch !== null, `The file '${tsFilePath}' seems to no longer have a string matching '${versionRgx.toString()}'.`);
94+
assert(
95+
patchMatch !== null,
96+
`The file '${tsFilePath}' seems to no longer have a string matching '${versionRgx.toString()}'.`,
97+
);
8898
const parsedPatch = patchMatch[1];
8999
if (parsedPatch !== patch) {
90100
throw new Error(`patch does not match. ${tsFilePath}: '${parsedPatch}; package.json: '${patch}'`);
91101
}
92102

93-
return tsFileContents.replace(versionRgx, `export const version: string = \`\${versionMajorMinor}.${nightlyPatch}\`;`);
103+
return tsFileContents.replace(
104+
versionRgx,
105+
`export const version: string = \`\${versionMajorMinor}.${nightlyPatch}\`;`,
106+
);
94107
}
95108

96109
/**

scripts/dtsBundler.mjs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ function isInternalDeclaration(node) {
5656
*/
5757
function getParentVariableStatement(node) {
5858
const declarationList = node.parent;
59-
assert(ts.isVariableDeclarationList(declarationList), `expected VariableDeclarationList at ${nodeToLocation(node)}`);
60-
assert(declarationList.declarations.length === 1, `expected VariableDeclarationList of length 1 at ${nodeToLocation(node)}`);
59+
assert(
60+
ts.isVariableDeclarationList(declarationList),
61+
`expected VariableDeclarationList at ${nodeToLocation(node)}`,
62+
);
63+
assert(
64+
declarationList.declarations.length === 1,
65+
`expected VariableDeclarationList of length 1 at ${nodeToLocation(node)}`,
66+
);
6167
const variableStatement = declarationList.parent;
6268
assert(ts.isVariableStatement(variableStatement), `expected VariableStatement at ${nodeToLocation(node)}`);
6369
return variableStatement;
@@ -235,7 +241,8 @@ function findInScope(name) {
235241
/** @type {(symbol: ts.Symbol | undefined, excludes?: ts.SymbolFlags) => boolean} */
236242
function isNonLocalAlias(symbol, excludes = ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace) {
237243
if (!symbol) return false;
238-
return (symbol.flags & (ts.SymbolFlags.Alias | excludes)) === ts.SymbolFlags.Alias || !!(symbol.flags & ts.SymbolFlags.Alias && symbol.flags & ts.SymbolFlags.Assignment);
244+
return (symbol.flags & (ts.SymbolFlags.Alias | excludes)) === ts.SymbolFlags.Alias
245+
|| !!(symbol.flags & ts.SymbolFlags.Alias && symbol.flags & ts.SymbolFlags.Assignment);
239246
}
240247

241248
/**
@@ -319,7 +326,13 @@ function verifyMatchingSymbols(decl) {
319326
}
320327

321328
if (symbolsConflict(symbolOfNode, symbolInScope)) {
322-
fail(`Declaration at ${nodeToLocation(decl)}\n references ${symbolOfNode.name} at ${symbolOfNode.declarations && nodeToLocation(symbolOfNode.declarations[0])},\n but containing scope contains a symbol with the same name declared at ${symbolInScope.declarations && nodeToLocation(symbolInScope.declarations[0])}`);
329+
fail(
330+
`Declaration at ${nodeToLocation(decl)}\n references ${symbolOfNode.name} at ${
331+
symbolOfNode.declarations && nodeToLocation(symbolOfNode.declarations[0])
332+
},\n but containing scope contains a symbol with the same name declared at ${
333+
symbolInScope.declarations && nodeToLocation(symbolInScope.declarations[0])
334+
}`,
335+
);
323336
}
324337
}
325338

0 commit comments

Comments
 (0)