Skip to content

Commit 71d1a3f

Browse files
authored
property handle misspelled namepath in @typedef tag (microsoft#13702)
1 parent 6512579 commit 71d1a3f

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

src/compiler/parser.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6693,10 +6693,15 @@ namespace ts {
66936693
typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
66946694
if (typedefTag.fullName) {
66956695
let rightNode = typedefTag.fullName;
6696-
while (rightNode.kind !== SyntaxKind.Identifier) {
6696+
while (true) {
6697+
if (rightNode.kind === SyntaxKind.Identifier || !rightNode.body) {
6698+
// if node is identifier - use it as name
6699+
// otherwise use name of the rightmost part that we were able to parse
6700+
typedefTag.name = rightNode.kind === SyntaxKind.Identifier ? rightNode : rightNode.name;
6701+
break;
6702+
}
66976703
rightNode = rightNode.body;
66986704
}
6699-
typedefTag.name = rightNode;
67006705
}
67016706
typedefTag.typeExpression = typeExpression;
67026707
skipWhitespace();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/a.js ===
2+
3+
No type information for this code./** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
4+
No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request;
5+
No type information for this code.
6+
No type information for this code./** @typedef {{ endTime: number, screenshots: !B.<string>}} */
7+
No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request;
8+
No type information for this code.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/a.js ===
2+
3+
/** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
4+
Animation.AnimationModel.ScreenshotCapture.Request;
5+
>Animation.AnimationModel.ScreenshotCapture.Request : any
6+
>Animation.AnimationModel.ScreenshotCapture : any
7+
>Animation.AnimationModel : any
8+
>Animation : any
9+
>AnimationModel : any
10+
>ScreenshotCapture : any
11+
>Request : any
12+
13+
/** @typedef {{ endTime: number, screenshots: !B.<string>}} */
14+
Animation.AnimationModel.ScreenshotCapture.Request;
15+
>Animation.AnimationModel.ScreenshotCapture.Request : any
16+
>Animation.AnimationModel.ScreenshotCapture : any
17+
>Animation.AnimationModel : any
18+
>Animation : any
19+
>AnimationModel : any
20+
>ScreenshotCapture : any
21+
>Request : any
22+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @allowJs: true
2+
// @noEmit: true
3+
4+
// @filename: a.js
5+
/** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
6+
Animation.AnimationModel.ScreenshotCapture.Request;
7+
8+
/** @typedef {{ endTime: number, screenshots: !B.<string>}} */
9+
Animation.AnimationModel.ScreenshotCapture.Request;

0 commit comments

Comments
 (0)