Skip to content

Commit 0736d8e

Browse files
authored
Merge pull request #15283 from Microsoft/Fix15237
Return Diagnostic.category from the server
2 parents 24814ec + 66eb9e3 commit 0736d8e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,7 @@ namespace ts {
33503350
messageText: string | DiagnosticMessageChain;
33513351
category: DiagnosticCategory;
33523352
code: number;
3353+
source?: string;
33533354
}
33543355

33553356
export enum DiagnosticCategory {

src/server/protocol.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,10 +1824,20 @@ namespace ts.server.protocol {
18241824
*/
18251825
text: string;
18261826

1827+
/**
1828+
* The category of the diagnostic message, e.g. "error" vs. "warning"
1829+
*/
1830+
category: string;
1831+
18271832
/**
18281833
* The error code of the diagnostic message.
18291834
*/
18301835
code?: number;
1836+
1837+
/**
1838+
* The name of the plugin reporting the message.
1839+
*/
1840+
source?: string;
18311841
}
18321842

18331843
export interface DiagnosticEventBody {

src/server/session.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ namespace ts.server {
7878
start: scriptInfo.positionToLineOffset(diag.start),
7979
end: scriptInfo.positionToLineOffset(diag.start + diag.length),
8080
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
81-
code: diag.code
81+
code: diag.code,
82+
category: DiagnosticCategory[diag.category].toLowerCase(),
83+
source: diag.source
8284
};
8385
}
8486

8587
function formatConfigFileDiag(diag: ts.Diagnostic): protocol.Diagnostic {
8688
return {
8789
start: undefined,
8890
end: undefined,
89-
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
91+
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
92+
category: DiagnosticCategory[diag.category].toLowerCase(),
93+
source: diag.source
9094
};
9195
}
9296

@@ -601,6 +605,7 @@ namespace ts.server {
601605
length: d.length,
602606
category: DiagnosticCategory[d.category].toLowerCase(),
603607
code: d.code,
608+
source: d.source,
604609
startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start),
605610
endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length)
606611
});

0 commit comments

Comments
 (0)