mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Fix scope of @typedef references (#16718)
* Fix scope of @typedef references * Remove unused variables
This commit is contained in:
parent
9013665e22
commit
2ccfe502f7
@ -275,6 +275,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getContainerNode(node: Node): Declaration {
|
||||
if (node.kind === SyntaxKind.JSDocTypedefTag) {
|
||||
// This doesn't just apply to the node immediately under the comment, but to everything in its parent's scope.
|
||||
// node.parent = the JSDoc comment, node.parent.parent = the node having the comment.
|
||||
// Then we get parent again in the loop.
|
||||
node = node.parent.parent;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
|
||||
20
tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts
Normal file
20
tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// Tests that the scope of @typedef is not just the node immediately below it.
|
||||
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
/////** @typedef {number} [|{| "isWriteAccess": true, "isDefinition": true |}T|] */
|
||||
////
|
||||
/////**
|
||||
//// * @return {[|T|]}
|
||||
//// */
|
||||
////function f(obj) { return 0; }
|
||||
////
|
||||
/////**
|
||||
//// * @return {[|T|]}
|
||||
//// */
|
||||
////function f2(obj) { return 0; }
|
||||
|
||||
verify.singleReferenceGroup("type T = number");
|
||||
Loading…
x
Reference in New Issue
Block a user