Skip to content

Commit 66eb9e3

Browse files
authored
Merge pull request #15296 from Microsoft/Fix15224
Fix #15224: Add a `source` property on Diagnostic interface
2 parents 75cdb47 + 5d7c75d commit 66eb9e3

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,15 +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;
18311836

18321837
/**
1833-
* The category of the diagnostic message, e.g. "error" vs. "warning"
1838+
* The name of the plugin reporting the message.
18341839
*/
1835-
category: string;
1840+
source?: string;
18361841
}
18371842

18381843
export interface DiagnosticEventBody {

src/server/session.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ namespace ts.server {
6868
end: scriptInfo.positionToLineOffset(diag.start + diag.length),
6969
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
7070
code: diag.code,
71-
category: DiagnosticCategory[diag.category].toLowerCase()
71+
category: DiagnosticCategory[diag.category].toLowerCase(),
72+
source: diag.source
7273
};
7374
}
7475

@@ -77,7 +78,8 @@ namespace ts.server {
7778
start: undefined,
7879
end: undefined,
7980
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
80-
category: DiagnosticCategory[diag.category].toLowerCase()
81+
category: DiagnosticCategory[diag.category].toLowerCase(),
82+
source: diag.source
8183
};
8284
}
8385

@@ -592,6 +594,7 @@ namespace ts.server {
592594
length: d.length,
593595
category: DiagnosticCategory[d.category].toLowerCase(),
594596
code: d.code,
597+
source: d.source,
595598
startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start),
596599
endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length)
597600
});

0 commit comments

Comments
 (0)