diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 38d6f558242..b7d0d6f0f0e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -640,6 +640,7 @@ namespace ts { function bindChildrenWorker(node: Node): void { if (checkUnreachable(node)) { bindEachChild(node); + bindJSDoc(node); return; } switch (node.kind) { diff --git a/tests/baselines/reference/jsdocBindingInUnreachableCode.symbols b/tests/baselines/reference/jsdocBindingInUnreachableCode.symbols new file mode 100644 index 00000000000..62ef96f854a --- /dev/null +++ b/tests/baselines/reference/jsdocBindingInUnreachableCode.symbols @@ -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)) + + }; +} + diff --git a/tests/baselines/reference/jsdocBindingInUnreachableCode.types b/tests/baselines/reference/jsdocBindingInUnreachableCode.types new file mode 100644 index 00000000000..d1d01d17e96 --- /dev/null +++ b/tests/baselines/reference/jsdocBindingInUnreachableCode.types @@ -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 + + }; +} + diff --git a/tests/cases/conformance/jsdoc/jsdocBindingInUnreachableCode.ts b/tests/cases/conformance/jsdoc/jsdocBindingInUnreachableCode.ts new file mode 100644 index 00000000000..2c4accf993b --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocBindingInUnreachableCode.ts @@ -0,0 +1,11 @@ +// @allowJs: true +// @noEmit: true +// @checkJs: true +// @Filename: bug27341.js +if (false) { + /** + * @param {string} s + */ + const x = function (s) { + }; +}