Skip to content

Commit f0e82ce

Browse files
committed
Add source to custom diagnostics
1 parent f8ef95f commit f0e82ce

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/diagnostics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as ts from "typescript";
2-
import { TranspileError } from './TranspileError';
2+
import { TranspileError } from "./TranspileError";
33

44
export const transpileError = (error: TranspileError) => ({
55
file: error.node.getSourceFile(),
66
start: error.node.getStart(),
77
length: error.node.getWidth(),
88
category: ts.DiagnosticCategory.Error,
99
code: 0,
10+
source: "typescript-to-lua",
1011
messageText: error.message,
1112
});
1213

@@ -16,6 +17,7 @@ export const tstlOptionsAreMovingToTheTstlObject = (tstl: Record<string, any>) =
1617
length: undefined,
1718
category: ts.DiagnosticCategory.Warning,
1819
code: 0,
20+
source: "typescript-to-lua",
1921
messageText:
2022
'TSTL options are moving to the "tstl" object. Adjust your tsconfig to look like\n' +
2123
JSON.stringify({ tstl }, undefined, 4)

test/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function transpileString(
1414
const { diagnostics, file } = transpileStringResult(str, options);
1515
if (!expectToBeDefined(file) || !expectToBeDefined(file.lua)) return "";
1616

17-
const errors = diagnostics.filter(diag => !ignoreDiagnostics || diag.code === 0);
17+
const errors = diagnostics.filter(d => !ignoreDiagnostics || d.source === "typescript-to-lua");
1818
expect(errors).not.toHaveDiagnostics();
1919

2020
return file.lua.trim();

0 commit comments

Comments
 (0)