Skip to content

Commit 2495e67

Browse files
authored
Merge pull request #16488 from Microsoft/add-jsdoc-to-eof-token
Add jsdoc to EOF token to catch missed `@typedef`s
2 parents 2a05bb1 + b967bbb commit 2495e67

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ namespace ts {
685685

686686
sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement);
687687
Debug.assert(token() === SyntaxKind.EndOfFileToken);
688-
sourceFile.endOfFileToken = <EndOfFileToken>parseTokenNode();
688+
sourceFile.endOfFileToken = addJSDocComment(parseTokenNode() as EndOfFileToken);
689689

690690
setExternalModuleIndicator(sourceFile);
691691

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/jsdoc/dtsEquivalent.js ===
2+
/** @typedef {{[k: string]: any}} AnyEffect */
3+
No type information for this code./** @typedef {number} Third */
4+
No type information for this code.=== tests/cases/conformance/jsdoc/index.js ===
5+
/** @type {AnyEffect} */
6+
let b;
7+
>b : Symbol(b, Decl(index.js, 1, 3))
8+
9+
/** @type {Third} */
10+
let c;
11+
>c : Symbol(c, Decl(index.js, 3, 3))
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/jsdoc/dtsEquivalent.js ===
2+
/** @typedef {{[k: string]: any}} AnyEffect */
3+
No type information for this code./** @typedef {number} Third */
4+
No type information for this code.=== tests/cases/conformance/jsdoc/index.js ===
5+
/** @type {AnyEffect} */
6+
let b;
7+
>b : { [k: string]: any; }
8+
9+
/** @type {Third} */
10+
let c;
11+
>c : number
12+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
// @Filename: dtsEquivalent.js
5+
/** @typedef {{[k: string]: any}} AnyEffect */
6+
/** @typedef {number} Third */
7+
// @Filename: index.js
8+
/** @type {AnyEffect} */
9+
let b;
10+
/** @type {Third} */
11+
let c;

0 commit comments

Comments
 (0)