Skip to content

Commit f86b34d

Browse files
committed
Make Diagnostics be a huge literal
1 parent 7c94ba2 commit f86b34d

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

scripts/processDiagnosticMessages.mjs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,12 @@ function buildInfoFileOutput(messageTable, inputFilePathRel) {
8888
"",
8989
"import { DiagnosticCategory, DiagnosticMessage } from \"./types\";",
9090
"",
91-
"function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage {",
92-
" return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated };",
93-
"}",
94-
"",
9591
"/** @internal */",
9692
"export const Diagnostics = {",
9793
];
9894
messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated }, name) => {
9995
const propName = convertPropertyName(name);
100-
const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : "";
101-
const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : "";
102-
const argReportsDeprecated = reportsDeprecated ? `${!argElidedInCompatabilityPyramid ? ", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined" : ""}, /*reportsDeprecated*/ ${reportsDeprecated}` : "";
103-
104-
result.push(` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}${argReportsDeprecated}),`);
96+
result.push(` ${propName}: { code: ${code}, category: DiagnosticCategory.${category}, key: "${createKey(propName, code)}", message: ${JSON.stringify(name)}, reportsUnnecessary: ${reportsUnnecessary}, elidedInCompatabilityPyramid: ${elidedInCompatabilityPyramid}, reportsDeprecated: ${reportsDeprecated} } satisfies DiagnosticMessage as DiagnosticMessage,`);
10597
});
10698

10799
result.push("};");

0 commit comments

Comments
 (0)