Skip to content

Commit 98e8d8d

Browse files
committed
Add error baselines
1 parent 5417e7c commit 98e8d8d

File tree

7 files changed

+99
-0
lines changed

7 files changed

+99
-0
lines changed

src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,5 +675,12 @@ namespace ts {
675675
}]
676676
});
677677
});
678+
679+
it("Allow trailing comments", () => {
680+
assertCompilerOptionsWithJsonText(`{} // no options`, "tsconfig.json", {
681+
compilerOptions: {},
682+
errors: []
683+
});
684+
});
678685
});
679686
}

src/testRunner/unittests/jsonParserRecovery.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ namespace ts {
44
it(name, () => {
55
const file = parseJsonText(name, text);
66
assert(file.parseDiagnostics.length, "Should have parse errors");
7+
Harness.Baseline.runBaseline(
8+
`jsonParserRecovery/${name.replace(/[^a-z0-9_-]/ig, "_")}.errors.txt`,
9+
Harness.Compiler.getErrorBaseline([{
10+
content: text,
11+
unitName: name
12+
}], file.parseDiagnostics));
13+
714
// Will throw if parse tree does not cover full input text
815
file.getChildren();
916
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
JSX(2,9): error TS1005: '{' expected.
2+
JSX(2,19): error TS1005: ',' expected.
3+
JSX(2,24): error TS1005: ',' expected.
4+
JSX(4,9): error TS1012: Unexpected token.
5+
JSX(4,15): error TS1005: ':' expected.
6+
JSX(15,10): error TS1005: '}' expected.
7+
8+
9+
==== JSX (6 errors) ====
10+
11+
interface Test {}
12+
~~~~~~~~~
13+
!!! error TS1005: '{' expected.
14+
~~~~
15+
!!! error TS1005: ',' expected.
16+
~
17+
!!! error TS1005: ',' expected.
18+
19+
const Header = () => (
20+
~~~~~
21+
!!! error TS1012: Unexpected token.
22+
~~~~~~
23+
!!! error TS1005: ':' expected.
24+
<div>
25+
<h1>Header</h1>
26+
<style jsx>
27+
{`
28+
h1 {
29+
color: red;
30+
}
31+
`}
32+
</style>
33+
</div>
34+
)
35+
36+
!!! error TS1005: '}' expected.
37+
!!! related TS1007 JSX:4:9: The parser expected to find a '}' to match the '{' token here.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Two comma-separated objects(1,3): error TS1012: Unexpected token.
2+
Two comma-separated objects(1,5): error TS1136: Property assignment expected.
3+
4+
5+
==== Two comma-separated objects (2 errors) ====
6+
{}, {}
7+
~
8+
!!! error TS1012: Unexpected token.
9+
~
10+
!!! error TS1136: Property assignment expected.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Two objects(1,4): error TS1012: Unexpected token.
2+
3+
4+
==== Two objects (1 errors) ====
5+
{} {}
6+
~
7+
!!! error TS1012: Unexpected token.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
TypeScript code(1,1): error TS1005: '{' expected.
2+
TypeScript code(1,11): error TS1005: ',' expected.
3+
TypeScript code(1,15): error TS1005: ',' expected.
4+
TypeScript code(1,18): error TS1012: Unexpected token.
5+
TypeScript code(1,22): error TS1005: '}' expected.
6+
7+
8+
==== TypeScript code (5 errors) ====
9+
interface Foo {} blah
10+
~~~~~~~~~
11+
!!! error TS1005: '{' expected.
12+
~~~
13+
!!! error TS1005: ',' expected.
14+
~
15+
!!! error TS1005: ',' expected.
16+
~~~~
17+
!!! error TS1012: Unexpected token.
18+
19+
!!! error TS1005: '}' expected.
20+
!!! related TS1007 TypeScript code:1:18: The parser expected to find a '}' to match the '{' token here.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trailing identifier(1,4): error TS1012: Unexpected token.
2+
trailing identifier(1,8): error TS1005: '}' expected.
3+
4+
5+
==== trailing identifier (2 errors) ====
6+
{} blah
7+
~~~~
8+
!!! error TS1012: Unexpected token.
9+
10+
!!! error TS1005: '}' expected.
11+
!!! related TS1007 trailing identifier:1:4: The parser expected to find a '}' to match the '{' token here.

0 commit comments

Comments
 (0)