Skip to content

Commit

Permalink
Fix expect call in dts test (#15766)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Dec 5, 2023
1 parent 15c7428 commit 2ca5d75
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/dts/unit/run.js
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 2ca5d75

Please sign in to comment.