Skip to content

Commit 8015e8b

Browse files
author
angelozerr
committed
Fix bug with diagnostic with TypeScript 2.1.0
1 parent d17183e commit 8015e8b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

core/ts.core/src/ts/internal/client/protocol/SemanticDiagnosticsSyncRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public void collect(JsonObject response) throws TypeScriptException {
3535
for (JsonValue item : body) {
3636
diagnostic = item.asObject();
3737
text = diagnostic.getString("text", null);
38+
if(text == null) {
39+
text = diagnostic.getString("message", null);
40+
}
3841
value = diagnostic.get("startLocation");
3942
if (value == null) {
4043
value = diagnostic.get("start");

core/ts.core/src/ts/internal/client/protocol/SyntacticDiagnosticsSyncRequest.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ public void collect(JsonObject response) throws TypeScriptException {
3131
String text = null;
3232
JsonObject start = null;
3333
JsonObject end = null;
34-
for (JsonValue value : body) {
35-
diagnostic = value.asObject();
34+
JsonValue value = null;
35+
for (JsonValue item : body) {
36+
diagnostic = item.asObject();
3637
text = diagnostic.getString("text", null);
37-
start = diagnostic.get("start").asObject();
38-
end = diagnostic.get("end").asObject();
38+
if (text == null) {
39+
text = diagnostic.getString("message", null);
40+
}
41+
value = diagnostic.get("startLocation");
42+
if (value == null) {
43+
value = diagnostic.get("start");
44+
}
45+
start = value.asObject();
46+
value = diagnostic.get("endLocation");
47+
if (value == null) {
48+
value = diagnostic.get("end");
49+
}
50+
end = value.asObject();
3951
getCollector().addDiagnostic(null, fileName, text, start.getInt("line", -1), start.getInt("offset", -1),
4052
end.getInt("line", -1), end.getInt("offset", -1));
4153
}

0 commit comments

Comments
 (0)