Skip to content

Commit 2dc447a

Browse files
authored
[torchci] Fix yarn format broken on main (unparseable satisfies) (#8272)
`yarn format` is failing on `main` after #8213. The advisor verdict maps used the TS `satisfies` operator, which the repo's prettier version can't parse — prettier throws `SyntaxError: ',' expected` on `} satisfies Record<...>` and `yarn format` exits non-zero (e.g. [this run](https://github.com/pytorch/test-infra/actions/runs/28980734998/job/85998682132)). It turns out that I use node 26 locally while CI use node 24. **Fix:** replace `{...} satisfies Record<AdvisorVerdictType, …>` with a direct `Record<AdvisorVerdictType, …>` type annotation on the three verdict maps (`AutorevertCell`, `AiAdvisorIndicator`, `AdvisorSection`). This keeps the same compile-time exhaustiveness — `tsc` still errors if a future verdict is added without updating a map — but uses syntax prettier understands. No behavior change. `prettier --check` and `tsc --noEmit` both pass locally.
1 parent cb9f8ca commit 2dc447a

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

torchci/components/autorevert/AutorevertCell.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ const HIGHLIGHT_LABELS: Record<string, string> = {
2929
restart: "Targeted for CI restart",
3030
};
3131

32-
const ADV_VERDICT_CLS: Record<string, string> = {
32+
const ADV_VERDICT_CLS: Record<AdvisorVerdictType, string> = {
3333
revert: styles.advRevert,
3434
related: styles.advRevert,
3535
not_related: styles.advNotRelated,
3636
infra_issue: styles.advInfra,
3737
garbage: styles.advGarbage,
3838
unsure: styles.advUnsure,
39-
} satisfies Record<AdvisorVerdictType, string>;
39+
};
4040

41-
const ADV_VERDICT_SHORT: Record<string, string> = {
41+
const ADV_VERDICT_SHORT: Record<AdvisorVerdictType, string> = {
4242
revert: "REV",
4343
related: "REV",
4444
not_related: "OK",
4545
infra_issue: "INF",
4646
garbage: "JNK",
4747
unsure: "?",
48-
} satisfies Record<AdvisorVerdictType, string>;
48+
};
4949

5050
interface AutorevertCellProps {
5151
events: CellEvent[];

torchci/components/job/AdvisorSection.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import {
55
} from "lib/advisorVerdictUtils";
66
import { useState } from "react";
77

8-
const VERDICT_COLORS: Record<string, { border: string; badge: string }> = {
8+
const VERDICT_COLORS: Record<
9+
AdvisorVerdictType,
10+
{ border: string; badge: string }
11+
> = {
912
revert: { border: "#d32f2f", badge: "#d32f2f" },
1013
related: { border: "#d32f2f", badge: "#d32f2f" },
1114
not_related: { border: "#388e3c", badge: "#2e7d32" },
1215
infra_issue: { border: "#57606a", badge: "#57606a" },
1316
garbage: { border: "#8d6e63", badge: "#6d4c41" },
1417
unsure: { border: "#757575", badge: "#616161" },
15-
} satisfies Record<AdvisorVerdictType, { border: string; badge: string }>;
18+
};
1619

1720
export default function AdvisorSection({
1821
verdict,

torchci/components/job/AiAdvisorIndicator.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function isDispatched(
6767
}
6868

6969
const VERDICT_CHIP_COLORS: Record<
70-
string,
70+
AdvisorVerdictType,
7171
"error" | "warning" | "success" | "default" | "info"
7272
> = {
7373
revert: "error",
@@ -76,19 +76,16 @@ const VERDICT_CHIP_COLORS: Record<
7676
not_related: "success",
7777
infra_issue: "info",
7878
garbage: "default",
79-
} satisfies Record<
80-
AdvisorVerdictType,
81-
"error" | "warning" | "success" | "default" | "info"
82-
>;
79+
};
8380

84-
const VERDICT_LABELS: Record<string, string> = {
81+
const VERDICT_LABELS: Record<AdvisorVerdictType, string> = {
8582
revert: "Revert",
8683
related: "Related",
8784
unsure: "Unsure",
8885
not_related: "Not Related",
8986
infra_issue: "Infra Issue",
9087
garbage: "Garbage Signal",
91-
} satisfies Record<AdvisorVerdictType, string>;
88+
};
9289

9390
export default function AiAdvisorIndicator({
9491
jobName,

0 commit comments

Comments
 (0)