From 030ef9b8c89ac6013176fa7874726622cb797275 Mon Sep 17 00:00:00 2001 From: Isabel Duan Date: Thu, 8 Aug 2024 09:24:42 -0700 Subject: [PATCH] update generated diagnostic messages for isolated declarations --- scripts/processDiagnosticMessages.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/processDiagnosticMessages.mjs b/scripts/processDiagnosticMessages.mjs index b3f398b802c18..ca1eef4b80382 100644 --- a/scripts/processDiagnosticMessages.mjs +++ b/scripts/processDiagnosticMessages.mjs @@ -93,20 +93,23 @@ function buildInfoFileOutput(messageTable, inputFilePathRel) { "}", "", "/** @internal */", - "export const Diagnostics = {", + "export const Diagnostics: Diagnostics = {", ]; + const interfaceResult = ["\r\ninterface Diagnostics {"]; messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated }, name) => { const propName = convertPropertyName(name); const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : ""; const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : ""; const argReportsDeprecated = reportsDeprecated ? `${!argElidedInCompatabilityPyramid ? ", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined" : ""}, /*reportsDeprecated*/ ${reportsDeprecated}` : ""; + interfaceResult.push(` ${propName}: DiagnosticMessage;`); result.push(` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}${argReportsDeprecated}),`); }); + interfaceResult.push("}"); result.push("};"); - return result.join("\r\n"); + return result.join("\r\n") + interfaceResult.join("\r\n"); } /**