Skip to content

Commit bf393ae

Browse files
authored
Check EOF token to get errors for JSDoc (#28000)
* Check EOF token to get errors for JSDoc * outputFile instead of noEmit for test
1 parent 69b1cb5 commit bf393ae

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27305,6 +27305,7 @@ namespace ts {
2730527305
clear(potentialNewTargetCollisions);
2730627306

2730727307
forEach(node.statements, checkSourceElement);
27308+
checkSourceElement(node.endOfFileToken);
2730827309

2730927310
checkDeferredNodes(node);
2731027311

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/conformance/jsdoc/eof.js(2,20): error TS2304: Cannot find name 'bad'.
2+
3+
4+
==== tests/cases/conformance/jsdoc/eof.js (1 errors) ====
5+
/**
6+
* @typedef {Array<bad>} Should have error here
7+
~~~
8+
!!! error TS2304: Cannot find name 'bad'.
9+
*/
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [eof.js]
2+
/**
3+
* @typedef {Array<bad>} Should have error here
4+
*/
5+
6+
7+
//// [output.js]
8+
/**
9+
* @typedef {Array<bad>} Should have error here
10+
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/jsdoc/eof.js ===
2+
/**
3+
No type information for this code. * @typedef {Array<bad>} Should have error here
4+
No type information for this code. */
5+
No type information for this code.
6+
No type information for this code.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/jsdoc/eof.js ===
2+
/**
3+
No type information for this code. * @typedef {Array<bad>} Should have error here
4+
No type information for this code. */
5+
No type information for this code.
6+
No type information for this code.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @outFile: output.js
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @Filename: eof.js
5+
6+
/**
7+
* @typedef {Array<bad>} Should have error here
8+
*/

0 commit comments

Comments
 (0)