mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
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:
parent
a58054df99
commit
9be846e1f2
@ -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;
|
||||
|
||||
@ -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'.
|
||||
*/
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
=== /a.js ===
|
||||
/**
|
||||
* @param {Ty} x
|
||||
*/
|
||||
function f(x) {}
|
||||
>f : (x: any) => void
|
||||
>x : any
|
||||
|
||||
/**
|
||||
* @typedef {CantResolveThis} Ty
|
||||
*/
|
||||
|
||||
13
tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts
Normal file
13
tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
|
||||
// @Filename: /a.js
|
||||
/**
|
||||
* @param {Ty} x
|
||||
*/
|
||||
function f(x) {}
|
||||
|
||||
/**
|
||||
* @typedef {CantResolveThis} Ty
|
||||
*/
|
||||
Loading…
x
Reference in New Issue
Block a user