diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2df1a583876..dc43faac435 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1458,9 +1458,8 @@ namespace ts { case SyntaxKind.JSDocTypedefTag: case SyntaxKind.JSDocCallbackTag: // js type aliases do not resolve names from their host, so skip past it - lastLocation = location; - location = getJSDocHost(location).parent; - continue; + location = getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; diff --git a/tests/baselines/reference/jsdocResolveNameFailureInTypedef.errors.txt b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.errors.txt new file mode 100644 index 00000000000..220be597bdb --- /dev/null +++ b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.errors.txt @@ -0,0 +1,15 @@ +/a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. + + +==== /a.js (1 errors) ==== + /** + * @param {Ty} x + */ + function f(x) {} + + /** + * @typedef {CantResolveThis} Ty + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'CantResolveThis'. + */ + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocResolveNameFailureInTypedef.symbols b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.symbols new file mode 100644 index 00000000000..36d8565cf01 --- /dev/null +++ b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.symbols @@ -0,0 +1,12 @@ +=== /a.js === +/** + * @param {Ty} x + */ +function f(x) {} +>f : Symbol(f, Decl(a.js, 0, 0)) +>x : Symbol(x, Decl(a.js, 3, 11)) + +/** + * @typedef {CantResolveThis} Ty + */ + diff --git a/tests/baselines/reference/jsdocResolveNameFailureInTypedef.types b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.types new file mode 100644 index 00000000000..4d88a942fe9 --- /dev/null +++ b/tests/baselines/reference/jsdocResolveNameFailureInTypedef.types @@ -0,0 +1,12 @@ +=== /a.js === +/** + * @param {Ty} x + */ +function f(x) {} +>f : (x: any) => void +>x : any + +/** + * @typedef {CantResolveThis} Ty + */ + diff --git a/tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts b/tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts new file mode 100644 index 00000000000..016893cfd7b --- /dev/null +++ b/tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts @@ -0,0 +1,13 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /a.js +/** + * @param {Ty} x + */ +function f(x) {} + +/** + * @typedef {CantResolveThis} Ty + */