Fix bug when name resolution fails in a @typedef: Don't set lastLocation (#24585)

* Fix bug when name resolution fails in a @typedef: Don't set `lastLocation`

* Add noEmit to test
This commit is contained in:
Andy 2018-06-01 16:49:54 -07:00 committed by GitHub
parent a58054df99
commit 9be846e1f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 3 deletions

View File

@ -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;

View File

@ -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'.
*/

View File

@ -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
*/

View File

@ -0,0 +1,12 @@
=== /a.js ===
/**
* @param {Ty} x
*/
function f(x) {}
>f : (x: any) => void
>x : any
/**
* @typedef {CantResolveThis} Ty
*/

View File

@ -0,0 +1,13 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: /a.js
/**
* @param {Ty} x
*/
function f(x) {}
/**
* @typedef {CantResolveThis} Ty
*/