Skip to content

Commit 6d92a29

Browse files
authored
Fix parent points in unreachable code (#27400) (#27406)
In the binder, unreachable code mistakenly skips the `bindJSDoc` call in `bindChildrenWorker`, which sets parent pointers. The fix is to call `bindJSDoc` in the case of unreachable code as well.
1 parent bde81de commit 6d92a29

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ namespace ts {
640640
function bindChildrenWorker(node: Node): void {
641641
if (checkUnreachable(node)) {
642642
bindEachChild(node);
643+
bindJSDoc(node);
643644
return;
644645
}
645646
switch (node.kind) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/jsdoc/bug27341.js ===
2+
if (false) {
3+
/**
4+
* @param {string} s
5+
*/
6+
const x = function (s) {
7+
>x : Symbol(x, Decl(bug27341.js, 4, 9))
8+
>s : Symbol(s, Decl(bug27341.js, 4, 24))
9+
10+
};
11+
}
12+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/conformance/jsdoc/bug27341.js ===
2+
if (false) {
3+
>false : false
4+
5+
/**
6+
* @param {string} s
7+
*/
8+
const x = function (s) {
9+
>x : (s: string) => void
10+
>function (s) { } : (s: string) => void
11+
>s : string
12+
13+
};
14+
}
15+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @allowJs: true
2+
// @noEmit: true
3+
// @checkJs: true
4+
// @Filename: bug27341.js
5+
if (false) {
6+
/**
7+
* @param {string} s
8+
*/
9+
const x = function (s) {
10+
};
11+
}

0 commit comments

Comments
 (0)