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.
This commit is contained in:
Nathan Shively-Sanders 2018-09-28 08:31:56 -07:00 committed by GitHub
parent bde81deed2
commit 6d92a2942f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 0 deletions

View File

@ -640,6 +640,7 @@ namespace ts {
function bindChildrenWorker(node: Node): void {
if (checkUnreachable(node)) {
bindEachChild(node);
bindJSDoc(node);
return;
}
switch (node.kind) {

View File

@ -0,0 +1,12 @@
=== tests/cases/conformance/jsdoc/bug27341.js ===
if (false) {
/**
* @param {string} s
*/
const x = function (s) {
>x : Symbol(x, Decl(bug27341.js, 4, 9))
>s : Symbol(s, Decl(bug27341.js, 4, 24))
};
}

View File

@ -0,0 +1,15 @@
=== tests/cases/conformance/jsdoc/bug27341.js ===
if (false) {
>false : false
/**
* @param {string} s
*/
const x = function (s) {
>x : (s: string) => void
>function (s) { } : (s: string) => void
>s : string
};
}

View File

@ -0,0 +1,11 @@
// @allowJs: true
// @noEmit: true
// @checkJs: true
// @Filename: bug27341.js
if (false) {
/**
* @param {string} s
*/
const x = function (s) {
};
}