Skip to content

Commit

Permalink
Fix expect call in dts test (prettier#15766)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 authored and medikoo committed Feb 16, 2024
1 parent 815691e commit c707e25
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/dts/unit/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

0 comments on commit c707e25

Please sign in to comment.