Skip to content

Commit 75cdb47

Browse files
committed
Return Diagnostic.category from the server
1 parent 6793466 commit 75cdb47

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/server/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,11 @@ namespace ts.server.protocol {
18281828
* The error code of the diagnostic message.
18291829
*/
18301830
code?: number;
1831+
1832+
/**
1833+
* The category of the diagnostic message, e.g. "error" vs. "warning"
1834+
*/
1835+
category: string;
18311836
}
18321837

18331838
export interface DiagnosticEventBody {

src/server/session.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ namespace ts.server {
6767
start: scriptInfo.positionToLineOffset(diag.start),
6868
end: scriptInfo.positionToLineOffset(diag.start + diag.length),
6969
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
70-
code: diag.code
70+
code: diag.code,
71+
category: DiagnosticCategory[diag.category].toLowerCase()
7172
};
7273
}
7374

7475
function formatConfigFileDiag(diag: ts.Diagnostic): protocol.Diagnostic {
7576
return {
7677
start: undefined,
7778
end: undefined,
78-
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
79+
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
80+
category: DiagnosticCategory[diag.category].toLowerCase()
7981
};
8082
}
8183

0 commit comments

Comments
 (0)