Fix expect call in dts test (#15766)

This commit is contained in:
Georgii Dolzhykov authored and GitHub committed 2023-12-06 00:10:45 +02:00
1 parent 15c742844f
commit 2ca5d757b7
1 file changed
+13 -1
+13 -1
View File
@@ -29,6 +29,18 @@ describe("Unit tests for dts files", () => {
/** @type {import("typescript").Diagnostic[]} */
const diagnostics = ts.getPreEmitDiagnostics(program);
expect(diagnostics).toEqual([]);
expect(diagnostics.map(formatDiagnostic)).toEqual([]);
});
});
/**
* @param {import("typescript").Diagnostic} diagnostic
*/
function formatDiagnostic({ file, start, code, messageText }) {
let location = "";
if (file) {
const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
location = `${file.fileName}:${line + 1}:${character + 1} `;
}
return `${location}TS${code}: ${messageText}`;
}