Fix scope of @typedef references (#16718)

* Fix scope of @typedef references

* Remove unused variables
This commit is contained in:
Andy 2017-06-28 13:30:23 -07:00 committed by GitHub
parent 9013665e22
commit 2ccfe502f7
2 changed files with 27 additions and 0 deletions

View File

@ -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) {

View 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");