@stll/oxlint-config 0.12.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +261 -1
  2. package/dist/cloud-setup-cli.cjs +6 -4
  3. package/dist/cloud-setup-cli.cjs.map +1 -1
  4. package/dist/cloud-setup-cli.mjs +3 -1
  5. package/dist/cloud-setup-cli.mjs.map +1 -1
  6. package/dist/compiler-packages.cjs +28 -0
  7. package/dist/compiler-packages.cjs.map +1 -0
  8. package/dist/compiler-packages.mjs +17 -0
  9. package/dist/compiler-packages.mjs.map +1 -0
  10. package/dist/consumer-compat-cli.cjs +1091 -0
  11. package/dist/consumer-compat-cli.cjs.map +1 -0
  12. package/dist/consumer-compat-cli.d.cts +1 -0
  13. package/dist/consumer-compat-cli.d.mts +1 -0
  14. package/dist/consumer-compat-cli.mjs +1089 -0
  15. package/dist/consumer-compat-cli.mjs.map +1 -0
  16. package/dist/index.cjs +50 -40
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +46 -41
  19. package/dist/index.d.mts +46 -41
  20. package/dist/index.mjs +50 -41
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/publish-build-target-nuxt-helper.cjs +71 -0
  23. package/dist/publish-build-target-nuxt-helper.cjs.map +1 -0
  24. package/dist/publish-build-target-nuxt-helper.d.cts +10 -0
  25. package/dist/publish-build-target-nuxt-helper.d.mts +10 -0
  26. package/dist/publish-build-target-nuxt-helper.mjs +68 -0
  27. package/dist/publish-build-target-nuxt-helper.mjs.map +1 -0
  28. package/dist/publish-build-target-vite-dts-helper.cjs +3 -0
  29. package/dist/publish-build-target-vite-dts-helper.d.cts +24 -0
  30. package/dist/publish-build-target-vite-dts-helper.d.mts +24 -0
  31. package/dist/publish-build-target-vite-dts-helper.mjs +2 -0
  32. package/dist/publish-build-target-vite-dts-helper2.cjs +372 -0
  33. package/dist/publish-build-target-vite-dts-helper2.cjs.map +1 -0
  34. package/dist/publish-build-target-vite-dts-helper2.mjs +359 -0
  35. package/dist/publish-build-target-vite-dts-helper2.mjs.map +1 -0
  36. package/dist/publish-contract-cli.cjs +983 -0
  37. package/dist/publish-contract-cli.cjs.map +1 -0
  38. package/dist/publish-contract-cli.d.cts +1 -0
  39. package/dist/publish-contract-cli.d.mts +1 -0
  40. package/dist/publish-contract-cli.mjs +981 -0
  41. package/dist/publish-contract-cli.mjs.map +1 -0
  42. package/dist/publish-contract.cjs +431 -0
  43. package/dist/publish-contract.cjs.map +1 -0
  44. package/dist/publish-contract.mjs +396 -0
  45. package/dist/publish-contract.mjs.map +1 -0
  46. package/dist/rolldown-runtime.cjs +28 -0
  47. package/dist/toolchain-changed-cli.cjs +34 -0
  48. package/dist/toolchain-changed-cli.cjs.map +1 -0
  49. package/dist/toolchain-changed-cli.d.cts +1 -0
  50. package/dist/toolchain-changed-cli.d.mts +1 -0
  51. package/dist/toolchain-changed-cli.mjs +34 -0
  52. package/dist/toolchain-changed-cli.mjs.map +1 -0
  53. package/dist/toolchain-changed.cjs +1470 -0
  54. package/dist/toolchain-changed.cjs.map +1 -0
  55. package/dist/toolchain-changed.mjs +1463 -0
  56. package/dist/toolchain-changed.mjs.map +1 -0
  57. package/dist/toolchain-check-cli.cjs +2 -1
  58. package/dist/toolchain-check-cli.cjs.map +1 -1
  59. package/dist/toolchain-check-cli.mjs +2 -1
  60. package/dist/toolchain-check-cli.mjs.map +1 -1
  61. package/dist/toolchain-guard.cjs +360 -1161
  62. package/dist/toolchain-guard.cjs.map +1 -1
  63. package/dist/toolchain-guard.mjs +338 -1100
  64. package/dist/toolchain-guard.mjs.map +1 -1
  65. package/dist/toolchain-inputs.cjs +926 -0
  66. package/dist/toolchain-inputs.cjs.map +1 -0
  67. package/dist/toolchain-inputs.mjs +816 -0
  68. package/dist/toolchain-inputs.mjs.map +1 -0
  69. package/dist/toolchain-schema.cjs +702 -0
  70. package/dist/toolchain-schema.cjs.map +1 -0
  71. package/dist/toolchain-schema.mjs +580 -0
  72. package/dist/toolchain-schema.mjs.map +1 -0
  73. package/dist/typecheck-parity-cli.cjs +38 -898
  74. package/dist/typecheck-parity-cli.cjs.map +1 -1
  75. package/dist/typecheck-parity-cli.mjs +39 -899
  76. package/dist/typecheck-parity-cli.mjs.map +1 -1
  77. package/dist/typecheck-parity.cjs +905 -0
  78. package/dist/typecheck-parity.cjs.map +1 -0
  79. package/dist/typecheck-parity.mjs +894 -0
  80. package/dist/typecheck-parity.mjs.map +1 -0
  81. package/dist/typecheck-probe-cli.cjs +176 -0
  82. package/dist/typecheck-probe-cli.cjs.map +1 -0
  83. package/dist/typecheck-probe-cli.d.cts +1 -0
  84. package/dist/typecheck-probe-cli.d.mts +1 -0
  85. package/dist/typecheck-probe-cli.mjs +174 -0
  86. package/dist/typecheck-probe-cli.mjs.map +1 -0
  87. package/package.json +43 -5
  88. package/toolchain.json +9 -1
@@ -1,913 +1,49 @@
1
1
  #!/usr/bin/env node
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- let node_fs = require("node:fs");
4
- let node_child_process = require("node:child_process");
5
- let node_path = require("node:path");
3
+ const require_typecheck_parity = require("./typecheck-parity.cjs");
4
+ const require_toolchain_changed = require("./toolchain-changed.cjs");
6
5
  let node_fs_promises = require("node:fs/promises");
7
- let node_module = require("node:module");
8
- let node_os = require("node:os");
9
- let node_perf_hooks = require("node:perf_hooks");
10
- let node_util = require("node:util");
11
- //#region src/typecheck-parity.ts
12
- const fixtures = [
13
- {
14
- name: "module-detection",
15
- flags: ["noUnusedLocals"],
16
- files: { "input.ts": "const unused = 1;" },
17
- codes: [6133]
18
- },
19
- {
20
- name: "skip-declaration-check",
21
- flags: ["skipLibCheck"],
22
- files: { "input.d.ts": "export declare const value: MissingType;" },
23
- codes: []
24
- },
25
- {
26
- name: "json-import",
27
- flags: ["resolveJsonModule"],
28
- files: {
29
- "data.json": "{ \"name\": \"value\" }",
30
- "input.ts": "import data from \"./data.json\"; export const value: string = data.name;"
31
- },
32
- codes: []
33
- },
34
- {
35
- name: "interop-import",
36
- flags: ["esModuleInterop"],
37
- files: {
38
- "types.d.cts": "declare const value: string; export = value;",
39
- "input.ts": "import value from \"./types.cjs\"; export const result: string = value;"
40
- },
41
- codes: []
42
- },
43
- {
44
- name: "valid-control",
45
- flags: [],
46
- files: { "input.ts": "export const value: string = \"correct\";" },
47
- codes: []
48
- },
49
- {
50
- name: "type-mismatch",
51
- flags: [],
52
- files: { "input.ts": "export const value: number = \"wrong\";" },
53
- codes: [2322]
54
- },
55
- {
56
- name: "missing-property",
57
- flags: [],
58
- files: { "input.ts": "export const value: { name: string } = {};" },
59
- codes: [2741]
60
- },
61
- {
62
- name: "strict-null",
63
- flags: ["strictNullChecks"],
64
- files: { "input.ts": "export const value: string = null;" },
65
- codes: [2322]
66
- },
67
- {
68
- name: "unchecked-index",
69
- flags: ["noUncheckedIndexedAccess"],
70
- files: { "input.ts": "export const value: string = [\"value\"][1];" },
71
- codes: [2322]
72
- },
73
- {
74
- name: "unused-local",
75
- flags: ["noUnusedLocals"],
76
- files: { "input.ts": "const unused = 1; export {};" },
77
- codes: [6133]
78
- },
79
- {
80
- name: "unused-parameter",
81
- flags: ["noUnusedParameters"],
82
- files: { "input.ts": "export const value = (unused: string) => 1;" },
83
- codes: [6133]
84
- },
85
- {
86
- name: "implicit-any",
87
- flags: ["noImplicitAny"],
88
- files: { "input.ts": "export const value = (input) => input;" },
89
- codes: [7006]
90
- },
91
- {
92
- name: "missing-import",
93
- flags: [],
94
- files: { "input.ts": "import { value } from \"./missing.js\"; export { value };" },
95
- codes: [2307]
96
- },
97
- {
98
- name: "side-effect-import",
99
- flags: ["noUncheckedSideEffectImports"],
100
- files: { "input.ts": "import \"./missing.js\";" },
101
- codes: [2882]
102
- },
103
- {
104
- name: "generic-constraint",
105
- flags: [],
106
- files: { "input.ts": "type Box<T extends string> = { value: T }; export type Value = Box<number>;" },
107
- codes: [2344]
108
- },
109
- {
110
- name: "exact-optional",
111
- flags: ["exactOptionalPropertyTypes"],
112
- files: { "input.ts": "export const value: { optional?: string } = { optional: undefined };" },
113
- codes: [2375]
114
- },
115
- {
116
- name: "fallthrough",
117
- flags: ["noFallthroughCasesInSwitch"],
118
- files: { "input.ts": "export const run = (value: number) => { switch (value) { case 0: value++; case 1: return value; default: return 0; } };" },
119
- codes: [7029]
120
- },
121
- {
122
- name: "implicit-override",
123
- flags: ["noImplicitOverride"],
124
- files: { "input.ts": "class Base { value = 1; } export class Child extends Base { value = 2; }" },
125
- codes: [4114]
126
- },
127
- {
128
- name: "implicit-return",
129
- flags: ["noImplicitReturns"],
130
- files: { "input.ts": "export const run = (value: boolean) => { if (value) return 1; };" },
131
- codes: [7030]
132
- },
133
- {
134
- name: "unknown-catch",
135
- flags: ["useUnknownInCatchVariables"],
136
- files: { "input.ts": "export const run = () => { try { return 1; } catch (error) { return error.message; } };" },
137
- codes: [18046]
138
- },
139
- {
140
- name: "index-property",
141
- flags: ["noPropertyAccessFromIndexSignature"],
142
- files: { "input.ts": "export const run = (value: Record<string, string>) => value.name;" },
143
- codes: [4111]
144
- },
145
- {
146
- name: "erasable-syntax",
147
- flags: ["erasableSyntaxOnly"],
148
- files: { "input.ts": "export enum Value { First }" },
149
- codes: [1294]
150
- },
151
- {
152
- name: "type-only-import",
153
- flags: ["verbatimModuleSyntax"],
154
- files: {
155
- "types.ts": "export type Value = string;",
156
- "input.ts": "import { Value } from \"./types.js\"; export const value: Value = \"value\";"
157
- },
158
- codes: [1484]
159
- },
160
- {
161
- name: "checked-javascript",
162
- flags: ["allowJs", "checkJs"],
163
- files: { "input.js": "/** @type {number} */\nexport const value = \"wrong\";" },
164
- codes: [2322]
165
- },
166
- {
167
- name: "strict-function",
168
- flags: ["strictFunctionTypes"],
169
- files: { "input.ts": "export const value: (input: string | number) => void = (input: string) => { input.toUpperCase(); };" },
170
- codes: [2322]
171
- },
172
- {
173
- name: "strict-initialization",
174
- flags: ["strictPropertyInitialization"],
175
- files: { "input.ts": "export class Value { name: string; }" },
176
- codes: [2564]
177
- },
178
- {
179
- name: "strict-bind",
180
- flags: ["strictBindCallApply"],
181
- files: { "input.ts": "const value = (input: string) => input; export const result = value.call(undefined, 1);" },
182
- codes: [2345]
183
- },
184
- {
185
- name: "implicit-this",
186
- flags: ["noImplicitThis"],
187
- files: { "input.ts": "export function value() { return this.name; }" },
188
- codes: [2683]
189
- },
190
- {
191
- name: "strict-iterator",
192
- flags: ["strictBuiltinIteratorReturn"],
193
- files: { "input.ts": "export const value: string = [\"value\"].values().next().value;" },
194
- codes: [2322]
195
- },
196
- {
197
- name: "always-strict",
198
- flags: ["alwaysStrict"],
199
- files: { "input.ts": "export const value = (eval: string) => eval;" },
200
- codes: [1215]
201
- },
202
- {
203
- name: "file-casing",
204
- flags: ["forceConsistentCasingInFileNames"],
205
- files: {
206
- "named.ts": "export const name = \"value\";",
207
- "Named.ts": "export const name = \"value\";",
208
- "input.ts": "import { name } from \"./named.js\"; import { name as other } from \"./Named.js\"; export const value = name + other;"
209
- },
210
- codes: [1149, 1261],
211
- anyCode: true
212
- }
213
- ];
214
- const diagnosticCodes = (text) => [...new Set([...text.matchAll(/(?:TS|(?:error|warning)\s+)(\d{4,5})/g)].map((match) => Number(match.at(1))))].sort((a, b) => a - b);
215
- const diagnosticParity = ({ expected, match, baseline, candidate }) => {
216
- const tscCodes = diagnosticCodes(baseline.output);
217
- const bunCodes = diagnosticCodes(candidate.output);
218
- const seeded = match === "any" ? expected.some((code) => tscCodes.includes(code)) : expected.every((code) => tscCodes.includes(code));
219
- const missing = tscCodes.filter((code) => !bunCodes.includes(code));
220
- const extra = bunCodes.filter((code) => !tscCodes.includes(code));
221
- const exitsMatch = expected.length === 0 ? baseline.status === 0 && candidate.status === 0 && tscCodes.length === 0 && bunCodes.length === 0 : baseline.status !== null && baseline.status !== 0 && candidate.status !== null && candidate.status !== 0;
222
- return {
223
- tscCodes,
224
- bunCodes,
225
- missing,
226
- extra,
227
- passed: seeded && exitsMatch && baseline.status === candidate.status && missing.length === 0 && extra.length === 0
228
- };
229
- };
230
- const configurationDiagnostics = (output, repo) => diagnosticSet(output, repo).filter((diagnostic) => /^(?:<config>:0:|.*\.json:[0-9]+:)(?:[56][0-9]{3}|1800[23]|2688)(?::|$)/.test(diagnostic) || /:1800[23](?::|$)/.test(diagnostic));
231
- const fixtureParity = (options) => {
232
- const result = diagnosticParity(options);
233
- const { baseline, candidate, expected, match } = options;
234
- const identityParity = compareDiagnosticSets({
235
- status: baseline.status,
236
- diagnostics: diagnosticSet(baseline.output, options.repo ?? process.cwd())
237
- }, {
238
- status: candidate.status,
239
- diagnostics: diagnosticSet(candidate.output, options.repo ?? process.cwd())
240
- });
241
- const configDiagnostics = [...configurationDiagnostics(baseline.output, options.repo ?? process.cwd()).map((diagnostic) => `TypeScript: ${diagnostic}`), ...configurationDiagnostics(candidate.output, options.repo ?? process.cwd()).map((diagnostic) => `Bun: ${diagnostic}`)];
242
- const seedFiles = new Set(options.seedFiles.map((file) => (0, node_path.resolve)(options.repo ?? process.cwd(), file)));
243
- const seededCodes = new Set(diagnosticSet(baseline.output, options.repo ?? process.cwd()).flatMap((diagnostic) => {
244
- const diagnosticMatch = /^(.*):[0-9]+:([0-9]+)$/.exec(diagnostic);
245
- const file = diagnosticMatch?.at(1);
246
- const code = diagnosticMatch?.at(2);
247
- return file !== void 0 && code !== void 0 && seedFiles.has((0, node_path.resolve)(options.repo ?? process.cwd(), file)) ? [Number(code)] : [];
248
- }));
249
- const active = expected.length > 0 && (match === "any" ? expected.some((code) => seededCodes.has(code)) : expected.every((code) => seededCodes.has(code)));
250
- const validExits = baseline.status !== null && candidate.status !== null && (result.tscCodes.length === 0 ? baseline.status === 0 : baseline.status !== 0) && (result.bunCodes.length === 0 ? candidate.status === 0 : candidate.status !== 0);
251
- return {
252
- ...result,
253
- active,
254
- configurationDiagnostics: configDiagnostics,
255
- identityMissing: identityParity.missing,
256
- identityExtra: identityParity.extra,
257
- passed: configDiagnostics.length === 0 && identityParity.passed && validExits && baseline.status === candidate.status && result.missing.length === 0 && result.extra.length === 0
258
- };
259
- };
260
- const fixtureRunPassed = (results) => results.some(({ active }) => active) && results.every(({ passed }) => passed);
261
- const diagnosticLocation = (file, repo) => {
262
- const normalized = file.replaceAll("\\", "/");
263
- const bundled = /^bundled:\/\/\/libs\/(lib\.[^/]+\.d\.ts)$/.exec(normalized);
264
- const installed = /(?:^|\/)node_modules\/(?:typescript|@typescript\/(?:native|typescript-[^/]+))\/(?:.*\/)?(lib\.[^/]+\.d\.ts)$/.exec(normalized);
265
- const library = bundled?.at(1) ?? installed?.at(1);
266
- return library === void 0 ? (0, node_path.relative)(repo, (0, node_path.resolve)(repo, file)).replaceAll("\\", "/") : `<lib>/${library}`;
267
- };
268
- const globalDiagnosticKey = (code, message) => `<config>:0:${code}:${message.trim().replaceAll(/\s+/g, " ")}`;
269
- const diagnosticSet = (output, repo) => {
270
- const clean = (0, node_util.stripVTControlCharacters)(output);
271
- const diagnostics = /* @__PURE__ */ new Set();
272
- for (const block of clean.matchAll(/<error\b([^>]*)>([\s\S]*?)<\/error>/g)) {
273
- const attributes = new Map([...(block.at(1) ?? "").matchAll(/(\w+)="([^"]*)"/g)].map((match) => [match.at(1), match.at(2)]));
274
- const file = attributes.get("file");
275
- const row = attributes.get("line");
276
- const code = attributes.get("code");
277
- if (code === void 0 || !/^TS\d+$/.test(code)) continue;
278
- if (file !== void 0 && row !== void 0 && row !== "0") diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`);
279
- else {
280
- const message = (block.at(2) ?? "").split(/<(?:source|related)\b/).at(0) ?? "";
281
- diagnostics.add(globalDiagnosticKey(code.slice(2), message));
282
- }
283
- }
284
- for (const line of clean.split("\n")) {
285
- if (line.startsWith("<error ")) continue;
286
- const match = /^(.*?)\((\d+),\d+\):\s*(?:error|warning) TS(\d+)/.exec(line) ?? /^(.*?):(\d+):\d+:\s*(?:error|warning) (?:TS)?(\d+)/.exec(line);
287
- if (match) {
288
- const [, file = "", row = "", code = ""] = match;
289
- diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);
290
- } else {
291
- const global = /^(?:error|warning) TS(\d+):\s*(.*)/.exec(line);
292
- if (global) diagnostics.add(globalDiagnosticKey(global.at(1) ?? "", global.at(2) ?? ""));
293
- }
294
- }
295
- return [...diagnostics].sort();
296
- };
297
- const compareDiagnosticSets = (baseline, candidate) => {
298
- const missing = baseline.diagnostics.filter((item) => !candidate.diagnostics.includes(item));
299
- const extra = candidate.diagnostics.filter((item) => !baseline.diagnostics.includes(item));
300
- const valid = (result) => result.status !== null && (result.diagnostics.length === 0 ? result.status === 0 : result.status !== 0);
301
- return {
302
- missing,
303
- extra,
304
- passed: valid(baseline) && valid(candidate) && baseline.status === candidate.status && missing.length === 0 && extra.length === 0
305
- };
306
- };
307
- const assertUnshadowedCheck = async (repo) => {
308
- const manifest = JSON.parse(await (0, node_fs_promises.readFile)((0, node_path.join)(repo, "package.json"), "utf8"));
309
- if (typeof manifest !== "object" || manifest === null) throw new Error("Invalid repository package.json");
310
- if ("scripts" in manifest && typeof manifest.scripts === "object" && manifest.scripts !== null && "check" in manifest.scripts) throw new Error("Repository package.json must not define a \"check\" script: it shadows Bun typechecking; rename that script before running parity");
311
- };
312
- const resolveCompiler = async (repo, policy) => {
313
- if (typeof policy !== "object" || policy === null || !("typescriptInstallLayouts" in policy) || !Array.isArray(policy.typescriptInstallLayouts)) throw new Error("toolchain.json must define typescriptInstallLayouts");
314
- const manifest = JSON.parse(await (0, node_fs_promises.readFile)((0, node_path.join)(repo, "package.json"), "utf8"));
315
- if (typeof manifest !== "object" || manifest === null) throw new Error("Invalid repository package.json");
316
- const dependencies = /* @__PURE__ */ new Map();
317
- for (const key of ["dependencies", "devDependencies"]) {
318
- if (!(key in manifest)) continue;
319
- const section = Reflect.get(manifest, key);
320
- if (typeof section === "object" && section !== null) for (const [name, specifier] of Object.entries(section)) dependencies.set(name, specifier);
321
- }
322
- const require = (0, node_module.createRequire)((0, node_path.join)(repo, "package.json"));
323
- for (const layout of [...policy.typescriptInstallLayouts].reverse()) {
324
- if (typeof layout !== "object" || layout === null || !("compilerPackage" in layout) || typeof layout.compilerPackage !== "string") throw new Error("Invalid TypeScript install layout");
325
- if (!dependencies.has(layout.compilerPackage)) continue;
326
- const packagePath = require.resolve(`${layout.compilerPackage}/package.json`);
327
- const installed = JSON.parse(await (0, node_fs_promises.readFile)(packagePath, "utf8"));
328
- if (typeof installed !== "object" || installed === null || !("bin" in installed) || typeof installed.bin !== "object" || installed.bin === null || !("tsc" in installed.bin) || typeof installed.bin.tsc !== "string") throw new Error(`${layout.compilerPackage} must expose a tsc binary`);
329
- if (!("compilerSpecifier" in layout) || typeof layout.compilerSpecifier !== "string") throw new Error("TypeScript install layout must define compilerSpecifier");
330
- const expectedVersion = layout.compilerSpecifier.replace(/^npm:typescript@/, "");
331
- if (!("version" in installed) || installed.version !== expectedVersion) throw new Error(`${layout.compilerPackage} must install TypeScript ${expectedVersion}`);
332
- return (0, node_path.resolve)(packagePath, "..", installed.bin.tsc);
333
- }
334
- throw new Error("Repository must declare a compiler from typescriptInstallLayouts");
335
- };
336
- const assertBunVersion = (bun, policy) => {
337
- if (typeof policy !== "object" || policy === null || !("bun" in policy) || typeof policy.bun !== "string") throw new Error("toolchain.json must define bun");
338
- const result = (0, node_child_process.spawnSync)(bun, ["--version"], { encoding: "utf8" });
339
- if (result.error) throw result.error;
340
- const installed = result.stdout.trim();
341
- if (result.status !== 0 || installed !== policy.bun) throw new Error(`Bun must be ${policy.bun}; selected runtime reports ${installed || "no version"}`);
342
- };
343
- const bunCheckArgs = (project, build = false) => [
344
- "check",
345
- "--no-pretty",
346
- "--all",
347
- ...build ? ["--build"] : [],
348
- ...project === void 0 ? [] : [`--project=${project}`]
349
- ];
350
- const canonicalOptions = (value) => {
351
- if (Array.isArray(value)) return `[${value.map(canonicalOptions).join(",")}]`;
352
- if (typeof value === "object" && value !== null) return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalOptions(Reflect.get(value, key))}`).join(",")}}`;
353
- if (value !== null && typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") throw new Error("Invalid effective compiler option");
354
- return JSON.stringify(value);
355
- };
356
- const EMIT_ONLY_OPTIONS = /* @__PURE__ */ new Set([
357
- "composite",
358
- "declaration",
359
- "declarationDir",
360
- "declarationMap",
361
- "emitDeclarationOnly",
362
- "outDir",
363
- "outFile",
364
- "rootDir",
365
- "sourceMap",
366
- "inlineSourceMap",
367
- "inlineSources",
368
- "incremental",
369
- "tsBuildInfoFile",
370
- "noEmitOnError",
371
- "importHelpers",
372
- "noEmitHelpers",
373
- "emitBOM",
374
- "mapRoot",
375
- "sourceRoot",
376
- "newLine",
377
- "preserveConstEnums",
378
- "removeComments",
379
- "stripInternal",
380
- "downlevelIteration",
381
- "isolatedDeclarations",
382
- "noEmit"
383
- ]);
384
- const resolvedCompilerOptions = ({ compilerOptions, configPath }) => {
385
- if (typeof compilerOptions !== "object" || compilerOptions === null || Array.isArray(compilerOptions)) throw new Error(`Invalid compiler options: ${configPath}`);
386
- const options = Object.fromEntries(Object.entries(compilerOptions));
387
- const directory = (0, node_path.dirname)(configPath);
388
- const rootDir = options["rootDir"];
389
- if (rootDir !== void 0 && typeof rootDir !== "string") throw new Error(`Invalid rootDir: ${configPath}`);
390
- if (typeof rootDir === "string") options["rootDir"] = (0, node_path.resolve)(directory, rootDir);
391
- let resolutionDirectory = directory;
392
- const absolutePaths = (value) => {
393
- if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) throw new Error(`Invalid compiler path option: ${configPath}`);
394
- return value.map((entry) => (0, node_path.resolve)(resolutionDirectory, entry));
395
- };
396
- for (const name of ["rootDirs", "typeRoots"]) if (name in options) options[name] = absolutePaths(options[name]);
397
- if ("baseUrl" in options) {
398
- const baseUrl = options["baseUrl"];
399
- if (typeof baseUrl !== "string") throw new Error(`Invalid baseUrl: ${configPath}`);
400
- resolutionDirectory = (0, node_path.resolve)(directory, baseUrl);
401
- options["baseUrl"] = resolutionDirectory;
402
- }
403
- if ("paths" in options) {
404
- const paths = options["paths"];
405
- if (typeof paths !== "object" || paths === null || Array.isArray(paths)) throw new Error(`Invalid paths: ${configPath}`);
406
- options["paths"] = Object.fromEntries(Object.entries(paths).map(([key, value]) => [key, absolutePaths(value)]));
407
- }
408
- return options;
409
- };
410
- const fixtureCompilerOptions = (args) => {
411
- const options = Object.fromEntries(Object.entries(resolvedCompilerOptions(args)).filter(([name]) => !EMIT_ONLY_OPTIONS.has(name)));
412
- options["noEmit"] = true;
413
- return options;
414
- };
415
- const fixtureInputs = ({ files, compilerOptions }) => {
416
- const inputs = files.filter((file) => /\.(?:[cm]?[jt]sx?|json)$/.test(file));
417
- for (const input of inputs) {
418
- if (/\.[cm]?jsx?$/.test(input) && compilerOptions["allowJs"] !== true) return {
419
- status: "inapplicable",
420
- reason: `${input} requires allowJs`
421
- };
422
- if (input.endsWith(".json") && compilerOptions["resolveJsonModule"] !== true) return {
423
- status: "inapplicable",
424
- reason: `${input} requires resolveJsonModule`
425
- };
426
- }
427
- return {
428
- status: "applicable",
429
- files: inputs
430
- };
431
- };
432
- const fixturePackageContext = (configPath) => {
433
- for (let folder = (0, node_path.dirname)(configPath);; folder = (0, node_path.dirname)(folder)) {
434
- try {
435
- const manifest = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(folder, "package.json"), "utf8"));
436
- if (typeof manifest !== "object" || manifest === null) throw new Error(`Invalid package.json: ${folder}`);
437
- if (!("type" in manifest)) return {};
438
- if (manifest.type !== "module" && manifest.type !== "commonjs") throw new Error(`Invalid package type: ${folder}`);
439
- return { type: manifest.type };
440
- } catch (error) {
441
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
442
- }
443
- if ((0, node_path.dirname)(folder) === folder) return {};
444
- }
445
- };
446
- const groupCompilerConfigs = (configs) => {
447
- const groups = /* @__PURE__ */ new Map();
448
- for (const config of configs) {
449
- const compilerOptions = fixtureCompilerOptions({
450
- compilerOptions: config.compilerOptions,
451
- configPath: config.path
452
- });
453
- const key = canonicalOptions({
454
- compilerOptions,
455
- resolutionContext: "typeRoots" in compilerOptions ? null : (0, node_path.dirname)(config.path),
456
- packageContext: config.packageContext ?? {}
457
- });
458
- const existing = groups.get(key);
459
- if (existing) existing.projects.push(config.path);
460
- else groups.set(key, {
461
- path: config.path,
462
- projects: [config.path],
463
- compilerOptions: config.compilerOptions,
464
- ...config.packageContext === void 0 ? {} : { packageContext: config.packageContext }
465
- });
466
- }
467
- return [...groups.values()];
468
- };
469
- const discoverConfigGroups = ({ repo, compiler, project }) => {
470
- const configs = [];
471
- const visited = /* @__PURE__ */ new Set();
472
- const projects = [];
473
- let build = false;
474
- const visit = (inputPath) => {
475
- const path = (0, node_fs.realpathSync)((0, node_fs.statSync)(inputPath).isDirectory() ? (0, node_path.join)(inputPath, "tsconfig.json") : inputPath);
476
- (0, node_fs.readFileSync)(path, "utf8");
477
- if (visited.has(path)) return;
478
- visited.add(path);
479
- const result = (0, node_child_process.spawnSync)(process.execPath, [
480
- compiler,
481
- "--showConfig",
482
- "--project",
483
- path
484
- ], {
485
- cwd: repo,
486
- encoding: "utf8",
487
- maxBuffer: 64 * 1024 * 1024
488
- });
489
- if (result.error) throw result.error;
490
- if (result.status !== 0) throw new Error(result.stdout + result.stderr);
491
- const config = JSON.parse(result.stdout);
492
- if (typeof config !== "object" || config === null) throw new Error(`Invalid resolved config: ${path}`);
493
- const references = "references" in config && Array.isArray(config.references) ? config.references : [];
494
- build ||= project === void 0 && references.length > 0;
495
- const compilerOptions = "compilerOptions" in config ? config.compilerOptions : {};
496
- if (typeof compilerOptions !== "object" || compilerOptions === null || Array.isArray(compilerOptions)) throw new Error(`Invalid compiler options: ${path}`);
497
- const rawFiles = "files" in config ? config.files : [];
498
- if (!Array.isArray(rawFiles)) throw new Error(`Invalid project files: ${path}`);
499
- const files = rawFiles.map((file) => {
500
- if (typeof file !== "string") throw new Error(`Invalid project file: ${path}`);
501
- return (0, node_path.resolve)((0, node_path.dirname)(path), file);
502
- });
503
- if (files.length === 0 && (project !== void 0 || references.length === 0)) throw new Error(`Project resolves to zero input files: ${path}`);
504
- const referencePaths = [];
505
- const resolvedReferences = [];
506
- projects.push({
507
- path,
508
- compilerOptions,
509
- files,
510
- references: referencePaths,
511
- resolvedReferences
512
- });
513
- if (files.length > 0 || references.length === 0) configs.push({
514
- path,
515
- compilerOptions,
516
- packageContext: fixturePackageContext(path)
517
- });
518
- for (const reference of references) {
519
- if (typeof reference !== "object" || reference === null || !("path" in reference) || typeof reference.path !== "string") throw new Error(`Invalid project reference: ${path}`);
520
- const referencedProject = (0, node_path.resolve)((0, node_path.dirname)(path), reference.path);
521
- const referencePath = (0, node_fs.realpathSync)((0, node_fs.statSync)(referencedProject).isDirectory() ? (0, node_path.join)(referencedProject, "tsconfig.json") : referencedProject);
522
- referencePaths.push(referencePath);
523
- resolvedReferences.push({
524
- ...reference,
525
- path: referencePath
526
- });
527
- if (project === void 0) visit(referencePath);
528
- }
529
- };
530
- const selected = (0, node_path.resolve)(repo, project ?? "tsconfig.json");
531
- const root = (0, node_fs.realpathSync)((0, node_fs.statSync)(selected).isDirectory() ? (0, node_path.join)(selected, "tsconfig.json") : selected);
532
- visit(root);
533
- const groups = groupCompilerConfigs(configs);
534
- if (groups.length === 0) throw new Error("No consumer compiler configurations to compare");
535
- return {
536
- build,
537
- groups,
538
- projects,
539
- root
540
- };
541
- };
542
- const discoverProjectGraphs = ({ repo, compiler, projects }) => {
543
- if (projects === void 0) return [discoverConfigGroups({
544
- repo,
545
- compiler
546
- })];
547
- if (projects.length === 0) throw new Error("Select at least one project");
548
- const graphs = /* @__PURE__ */ new Map();
549
- for (const project of projects) {
550
- const graph = discoverConfigGroups({
551
- repo,
552
- compiler,
553
- project
554
- });
555
- if (!graphs.has(graph.root)) graphs.set(graph.root, graph);
556
- }
557
- return [...graphs.values()];
558
- };
559
- const timedCommand = ({ command, args, repo }) => {
560
- const started = node_perf_hooks.performance.now();
561
- const result = (0, node_child_process.spawnSync)("/usr/bin/time", [
562
- process.platform === "darwin" ? "-l" : "-v",
563
- command,
564
- ...args
565
- ], {
566
- cwd: repo,
567
- encoding: "utf8",
568
- maxBuffer: 64 * 1024 * 1024
569
- });
570
- if (result.error) throw result.error;
571
- const rss = process.platform === "darwin" ? /([0-9]+)\s+maximum resident set size/.exec(result.stderr) : /Maximum resident set size \(kbytes\):\s*([0-9]+)/.exec(result.stderr);
572
- if (!rss) throw new Error("Cannot measure maximum RSS with /usr/bin/time");
573
- return {
574
- status: result.status,
575
- output: result.stdout + result.stderr,
576
- wall: (node_perf_hooks.performance.now() - started) / 1e3,
577
- maxRssKiB: Number(rss[1]) / (process.platform === "darwin" ? 1024 : 1)
578
- };
579
- };
580
- const NO_WORK_MAX_RSS_KIB = 16 * 1024;
581
- const NO_WORK_MAX_WALL_SECONDS = .25;
582
- const sourceDiagnosticSet = ({ output, repo, scratch, configPaths }) => {
583
- const configs = new Set(configPaths.map((path) => (0, node_path.resolve)(path)));
584
- const invalid = new Set(configurationDiagnostics(output, repo));
585
- return diagnosticSet(output, repo).filter((diagnostic) => {
586
- if (invalid.has(diagnostic)) return false;
587
- if (diagnostic.startsWith("<config>:")) return true;
588
- const file = /^(.*):[0-9]+:[0-9]+$/.exec(diagnostic)?.at(1);
589
- if (file === void 0) return false;
590
- const path = (0, node_path.resolve)(repo, file);
591
- return !configs.has(path) && path !== scratch && !path.startsWith(scratch + "/");
592
- });
593
- };
594
- const diagnosticExitStatus = ({ status, output, repo }) => status === 2 && configurationDiagnostics(output, repo).length === 0 && diagnosticSet(output, repo).some((diagnostic) => !diagnostic.startsWith("<config>:")) ? 1 : status;
595
- const repositoryDiagnosticComparison = ({ baseline, candidate, repo, scratch, configPaths }) => {
596
- const configs = new Set(configPaths.map((path) => (0, node_path.resolve)(path)));
597
- const configurationErrors = (output) => [.../* @__PURE__ */ new Set([...configurationDiagnostics(output, repo), ...diagnosticSet(output, repo).filter((diagnostic) => {
598
- const file = /^(.*):[0-9]+:[0-9]+$/.exec(diagnostic)?.at(1);
599
- return file !== void 0 && configs.has((0, node_path.resolve)(repo, file));
600
- })])];
601
- const configurationErrorsFound = [...configurationErrors(baseline.output).map((diagnostic) => `TypeScript: ${diagnostic}`), ...configurationErrors(candidate.output).map((diagnostic) => `Bun: ${diagnostic}`)];
602
- const diagnostics = (output) => sourceDiagnosticSet({
603
- output,
604
- repo,
605
- scratch,
606
- configPaths
607
- });
608
- const comparison = compareDiagnosticSets({
609
- status: baseline.status,
610
- diagnostics: diagnostics(baseline.output)
611
- }, {
612
- status: candidate.status,
613
- diagnostics: diagnostics(candidate.output)
614
- });
615
- return {
616
- ...comparison,
617
- passed: configurationErrorsFound.length === 0 && comparison.passed,
618
- configurationDiagnostics: configurationErrorsFound
619
- };
620
- };
621
- const temporaryProjectTree = async ({ scratch, projects }) => {
622
- const contexts = /* @__PURE__ */ new Map();
623
- const linkedFolders = /* @__PURE__ */ new Set();
624
- for (const project of projects) {
625
- const path = (0, node_path.join)(scratch, "projects", (0, node_path.relative)((0, node_path.resolve)("/"), project));
626
- const folder = (0, node_path.dirname)(path);
627
- await (0, node_fs_promises.mkdir)(folder, { recursive: true });
628
- for (let original = (0, node_path.dirname)(project);; original = (0, node_path.dirname)(original)) {
629
- if (!linkedFolders.has(original)) {
630
- linkedFolders.add(original);
631
- const modules = (0, node_path.join)(original, "node_modules");
632
- try {
633
- if ((0, node_fs.statSync)(modules).isDirectory()) {
634
- const destination = (0, node_path.join)(scratch, "projects", (0, node_path.relative)((0, node_path.resolve)("/"), original));
635
- await (0, node_fs_promises.mkdir)(destination, { recursive: true });
636
- await (0, node_fs_promises.symlink)(modules, (0, node_path.join)(destination, "node_modules"), "dir");
637
- }
638
- } catch (error) {
639
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
640
- }
641
- }
642
- if ((0, node_path.dirname)(original) === original) break;
643
- }
644
- contexts.set(project, {
645
- path,
646
- folder,
647
- outputFolder: (0, node_path.join)(folder, `${(0, node_path.basename)(path)}.parity-output`)
648
- });
649
- }
650
- return contexts;
651
- };
652
- const compareRepository = async ({ repo, compiler, bun, graph }) => {
653
- const scratch = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "parity-repository-"));
654
- try {
655
- const contexts = await temporaryProjectTree({
656
- scratch,
657
- projects: graph.projects.map(({ path }) => path)
658
- });
659
- const configPaths = new Map([...contexts].map(([original, context]) => [original, context.path]));
660
- const requiredOutputs = new Set(graph.projects.flatMap(({ references }) => references));
661
- for (const project of graph.projects) {
662
- const context = contexts.get(project.path);
663
- if (context === void 0) throw new Error(`Missing temporary project: ${project.path}`);
664
- const { path: configPath, outputFolder } = context;
665
- const options = resolvedCompilerOptions({
666
- configPath: project.path,
667
- compilerOptions: project.compilerOptions
668
- });
669
- const declarationsRequired = graph.build && requiredOutputs.has(project.path) && options["composite"] === true;
670
- options["noEmit"] = !graph.build || options["noEmit"] === true && !declarationsRequired;
671
- const relocatesOutput = options["noEmit"] !== true || "outDir" in options || "declarationDir" in options;
672
- if (!("rootDir" in options) && relocatesOutput) options["rootDir"] = (0, node_path.dirname)(project.path);
673
- if (relocatesOutput) options["outDir"] = (0, node_path.join)(outputFolder, "output");
674
- const emitsDeclarations = options["declaration"] === true || options["composite"] === true && options["declaration"] !== false;
675
- if (graph.build && emitsDeclarations || "declarationDir" in options) options["declarationDir"] = (0, node_path.join)(outputFolder, "declarations");
676
- if (graph.build || options["incremental"] === true || options["composite"] === true) options["tsBuildInfoFile"] = (0, node_path.join)(outputFolder, "project.tsbuildinfo");
677
- if (graph.build) {
678
- options["declarationMap"] = false;
679
- if (emitsDeclarations) options["emitDeclarationOnly"] = true;
680
- options["noEmitOnError"] = false;
681
- }
682
- if ("outFile" in options) options["outFile"] = (0, node_path.join)(outputFolder, "bundle.js");
683
- await (0, node_fs_promises.writeFile)(configPath, JSON.stringify({
684
- compilerOptions: options,
685
- files: project.files,
686
- include: [],
687
- references: graph.build ? project.references.map((path) => {
688
- const temporary = configPaths.get(path);
689
- if (temporary === void 0) throw new Error(`Missing referenced temporary project: ${path}`);
690
- return { path: temporary };
691
- }) : project.resolvedReferences
692
- }));
693
- }
694
- const root = configPaths.get(graph.root);
695
- if (root === void 0) throw new Error("Missing temporary root config");
696
- const baselineRaw = timedCommand({
697
- command: process.execPath,
698
- args: [
699
- compiler,
700
- ...graph.build ? [
701
- "--build",
702
- "--force",
703
- root
704
- ] : [
705
- "--noEmit",
706
- "--project",
707
- root
708
- ],
709
- "--pretty",
710
- "false"
711
- ],
712
- repo
713
- });
714
- const candidate = timedCommand({
715
- command: bun,
716
- args: bunCheckArgs(root, graph.build),
717
- repo
718
- });
719
- const sourceDiagnostics = (output) => sourceDiagnosticSet({
720
- output,
721
- repo,
722
- scratch,
723
- configPaths: graph.projects.map(({ path }) => path)
724
- });
725
- const baselineDiagnostics = sourceDiagnostics(baselineRaw.output);
726
- const baseline = {
727
- ...baselineRaw,
728
- rawStatus: baselineRaw.status,
729
- status: diagnosticExitStatus({
730
- status: baselineRaw.status,
731
- output: baselineRaw.output,
732
- repo
733
- }),
734
- diagnostics: baselineDiagnostics
735
- };
736
- const repository = repositoryDiagnosticComparison({
737
- baseline,
738
- candidate,
739
- repo,
740
- scratch,
741
- configPaths: [...graph.projects.map(({ path }) => path), ...configPaths.values()]
742
- });
743
- return {
744
- baseline,
745
- candidate: {
746
- ...candidate,
747
- rawStatus: candidate.status,
748
- diagnostics: sourceDiagnostics(candidate.output)
749
- },
750
- repository
751
- };
752
- } finally {
753
- await (0, node_fs_promises.rm)(scratch, {
754
- recursive: true,
755
- force: true
756
- });
757
- }
758
- };
759
- const runTypecheckParity = async ({ repo, policy, bun = process.versions.bun ? process.execPath : "bun", projects }) => {
760
- await assertUnshadowedCheck(repo);
761
- assertBunVersion(bun, policy);
762
- const compiler = await resolveCompiler(repo, policy);
763
- const graphs = discoverProjectGraphs({
764
- repo,
765
- compiler,
766
- projects
767
- });
768
- const results = [];
769
- for (const graph of graphs) results.push(await runConfigParity({
770
- repo,
771
- compiler,
772
- bun,
773
- graph
774
- }));
775
- return results.every((passed) => passed);
776
- };
777
- const runConfigParity = async ({ repo, compiler, bun, graph }) => {
778
- const { groups } = graph;
779
- const { baseline, candidate, repository } = await compareRepository({
780
- repo,
781
- compiler,
782
- bun,
783
- graph
784
- });
785
- console.log("Class | TypeScript diagnostics | Bun diagnostics | Result");
786
- console.log(`repository | ${baseline.diagnostics.join(",")} | ${candidate.diagnostics.join(",")} | ${repository.passed ? "PASS" : "FAIL"}`);
787
- console.log(`repository tsc: wall=${baseline.wall.toFixed(3)}s maxRSS=${baseline.maxRssKiB}KiB exit=${baseline.rawStatus}`);
788
- console.log(`repository bun: wall=${candidate.wall.toFixed(3)}s maxRSS=${candidate.maxRssKiB}KiB exit=${candidate.rawStatus}`);
789
- for (const diagnostic of repository.configurationDiagnostics) console.error(`FAIL: invalid repository configuration: ${diagnostic}`);
790
- const scratch = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "typecheck-parity-"));
791
- const groupResults = [];
792
- try {
793
- for (const [index, group] of groups.entries()) {
794
- console.log(`Config group ${index + 1}: ${(0, node_path.relative)(repo, group.path)} (${group.projects.length} projects)`);
795
- const results = [];
796
- let tscWall = 0;
797
- let bunWall = 0;
798
- let tscRss = 0;
799
- let bunRss = 0;
800
- const context = (await temporaryProjectTree({
801
- scratch: (0, node_path.join)(scratch, `config-${index + 1}`),
802
- projects: [group.path]
803
- })).get(group.path);
804
- if (context === void 0) throw new Error(`Missing temporary fixture context: ${group.path}`);
805
- const groupFolder = context.folder;
806
- const compilerOptions = fixtureCompilerOptions({
807
- compilerOptions: group.compilerOptions,
808
- configPath: group.path
809
- });
810
- await (0, node_fs_promises.writeFile)((0, node_path.join)(groupFolder, "package.json"), JSON.stringify(group.packageContext ?? fixturePackageContext(group.path)));
811
- for (const fixture of fixtures) {
812
- const inputs = fixtureInputs({
813
- files: Object.keys(fixture.files),
814
- compilerOptions
815
- });
816
- if (inputs.status === "inapplicable") {
817
- console.log(`${fixture.name} (inactive under this config: ${inputs.reason}) | | | INACTIVE`);
818
- continue;
819
- }
820
- const folder = (0, node_path.join)(groupFolder, fixture.name);
821
- await (0, node_fs_promises.mkdir)(folder);
822
- await (0, node_fs_promises.writeFile)((0, node_path.join)(folder, "tsconfig.json"), JSON.stringify({
823
- compilerOptions,
824
- files: inputs.files,
825
- include: [],
826
- exclude: []
827
- }));
828
- for (const [name, content] of Object.entries(fixture.files)) await (0, node_fs_promises.writeFile)((0, node_path.join)(folder, name), content);
829
- const tsc = timedCommand({
830
- command: process.execPath,
831
- args: [
832
- compiler,
833
- "--noEmit",
834
- "--pretty",
835
- "false",
836
- "-p",
837
- folder
838
- ],
839
- repo: folder
840
- });
841
- const checked = timedCommand({
842
- command: bun,
843
- args: [...bunCheckArgs(folder), "--threads=1"],
844
- repo: folder
845
- });
846
- const result = fixtureParity({
847
- seedFiles: inputs.files,
848
- expected: fixture.codes,
849
- match: fixture.anyCode ? "any" : "all",
850
- repo: folder,
851
- baseline: {
852
- ...tsc,
853
- status: diagnosticExitStatus({
854
- status: tsc.status,
855
- output: tsc.output,
856
- repo: folder
857
- })
858
- },
859
- candidate: checked
860
- });
861
- results.push(result);
862
- tscWall += tsc.wall;
863
- bunWall += checked.wall;
864
- tscRss = Math.max(tscRss, tsc.maxRssKiB);
865
- bunRss = Math.max(bunRss, checked.maxRssKiB);
866
- if (result.configurationDiagnostics.length > 0) {
867
- console.error(`FAIL: invalid fixture configuration for ${fixture.name}: ${result.configurationDiagnostics.join("; ")}`);
868
- console.log(`${fixture.name} | configuration error | configuration error | FAIL`);
869
- continue;
870
- }
871
- let outcome = "INACTIVE";
872
- if (result.active) outcome = result.passed ? "PASS" : "FAIL";
873
- console.log(`${fixture.name}${result.active ? "" : " (inactive under this config)"} | ${result.tscCodes.join(",")} | ${result.bunCodes.join(",")} | ${outcome}`);
874
- if (!result.active && !result.passed) console.error(`FAIL: diagnostic comparison differs for inactive class ${fixture.name}: TypeScript exit=${tsc.status}, Bun exit=${checked.status}; missing=${result.identityMissing.join(",")}; extra=${result.identityExtra.join(",")}`);
875
- if (result.active && result.bunCodes.length === 0) {
876
- console.error(`FAIL: Bun returned zero diagnostics for active class ${fixture.name} (exit ${checked.status})`);
877
- if (checked.maxRssKiB <= NO_WORK_MAX_RSS_KIB && checked.wall <= NO_WORK_MAX_WALL_SECONDS) console.error(`Bun measured little checker work: wall=${checked.wall.toFixed(3)}s maxRSS=${checked.maxRssKiB}KiB; verify the checker invocation`);
878
- }
879
- }
880
- console.log(`fixtures tsc: wall=${tscWall.toFixed(3)}s maxRSS=${tscRss}KiB`);
881
- console.log(`fixtures bun: wall=${bunWall.toFixed(3)}s maxRSS=${bunRss}KiB`);
882
- if (!results.some(({ active }) => active)) console.error(`FAIL: zero seeded fixture classes active under config group ${index + 1}`);
883
- groupResults.push(fixtureRunPassed(results));
884
- }
885
- } finally {
886
- await (0, node_fs_promises.rm)(scratch, {
887
- recursive: true,
888
- force: true
889
- });
890
- }
891
- return repository.passed && groupResults.every((passed) => passed);
892
- };
893
- //#endregion
894
6
  //#region src/typecheck-parity-args.ts
895
- const parityUsage = "Usage: stll-typecheck-parity [--project <tsconfig>]... (run from repository root)\n stll-typecheck-parity --help";
7
+ const parityUsage = "Usage: stll-typecheck-parity [--changed-since <git-ref>] [--project <tsconfig>]... (run from repository root)\n stll-typecheck-parity --help";
896
8
  const parseParityArguments = (args) => {
897
9
  if (args.length === 1 && args.at(0) === "--help") return { mode: "help" };
898
10
  const projects = [];
11
+ let changedSince;
899
12
  for (let index = 0; index < args.length; index += 1) {
900
13
  const project = args.at(index + 1);
901
- if (args.at(index) !== "--project" || project === void 0 || project.trim() === "" || project.startsWith("--")) throw new Error(parityUsage);
902
- projects.push(project);
14
+ const option = args.at(index);
15
+ if (option !== "--project" && option !== "--changed-since" || project === void 0 || project.trim() === "" || project.startsWith("--")) throw new Error(parityUsage);
16
+ if (option === "--project") projects.push(project);
17
+ else {
18
+ if (changedSince !== void 0) throw new Error(parityUsage);
19
+ changedSince = project;
20
+ }
903
21
  index += 1;
904
22
  }
905
- return projects.length === 0 ? { mode: "default" } : {
23
+ return projects.length === 0 ? {
24
+ mode: "default",
25
+ ...changedSince === void 0 ? {} : { changedSince }
26
+ } : {
906
27
  mode: "selected",
907
- projects
28
+ projects,
29
+ ...changedSince === void 0 ? {} : { changedSince }
908
30
  };
909
31
  };
910
32
  //#endregion
33
+ //#region src/typecheck-parity-selection.ts
34
+ /** CI forcing considers every tool; compiler parity includes Bun, TS, and unclassified shared declarations. */
35
+ const runSelectedTypecheckParity = async ({ repo, since, run, detect = require_toolchain_changed.detectToolchainChanges, output = (text) => process.stdout.write(text) }) => {
36
+ if (since === void 0) return run();
37
+ const result = await detect({
38
+ repo,
39
+ since
40
+ });
41
+ if (result.status === "unreadable") return run();
42
+ if (result.tools.some((tool) => tool === "bun" || tool === "typescript" || tool === "shared")) return run();
43
+ output(`parity skipped: toolchain unchanged since ${since} (bun ${result.current.bun.join(", ") || "not declared"}, typescript ${result.current.typescript.join(", ") || "not declared"})\n`);
44
+ return true;
45
+ };
46
+ //#endregion
911
47
  //#region src/typecheck-parity-cli.ts
912
48
  const main = async () => {
913
49
  const args = parseParityArguments(process.argv.slice(2));
@@ -916,10 +52,14 @@ const main = async () => {
916
52
  return;
917
53
  }
918
54
  const policy = JSON.parse(await (0, node_fs_promises.readFile)(new URL("../toolchain.json", require("url").pathToFileURL(__filename).href), "utf8"));
919
- if (!await runTypecheckParity({
55
+ if (!await runSelectedTypecheckParity({
920
56
  repo: process.cwd(),
921
- policy,
922
- ...args.mode === "selected" ? { projects: args.projects } : {}
57
+ since: args.changedSince,
58
+ run: () => require_typecheck_parity.runTypecheckParity({
59
+ repo: process.cwd(),
60
+ policy,
61
+ ...args.mode === "selected" ? { projects: args.projects } : {}
62
+ })
923
63
  })) process.exitCode = 1;
924
64
  };
925
65
  main().catch((error) => {