mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-30 04:16:48 -05:00
fix(37539): extend scope for function expressions to include JSDoc (#41364)
This commit is contained in:
@@ -2569,7 +2569,7 @@ namespace ts {
|
||||
return result || emptyArray;
|
||||
}
|
||||
|
||||
function getNextJSDocCommentLocation(node: Node) {
|
||||
export function getNextJSDocCommentLocation(node: Node) {
|
||||
const parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.PropertyAssignment ||
|
||||
parent.kind === SyntaxKind.ExportAssignment ||
|
||||
|
||||
@@ -1206,8 +1206,13 @@ namespace ts.FindAllReferences {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// The search scope is the container node
|
||||
scope = container;
|
||||
if (isFunctionExpression(scope)) {
|
||||
let next: Node | undefined;
|
||||
while (next = getNextJSDocCommentLocation(scope)) {
|
||||
scope = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If symbol.parent, this means we are in an export of an external module. (Otherwise we would have returned `undefined` above.)
|
||||
|
||||
10
tests/baselines/reference/renameFunctionParameter1.baseline
Normal file
10
tests/baselines/reference/renameFunctionParameter1.baseline
Normal file
@@ -0,0 +1,10 @@
|
||||
/*====== /tests/cases/fourslash/renameFunctionParameter1.ts ======*/
|
||||
|
||||
function Foo() {
|
||||
/**
|
||||
* @param {number} RENAME
|
||||
*/
|
||||
this.foo = function foo([|RENAME|]) {
|
||||
return RENAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/*====== /tests/cases/fourslash/renameFunctionParameter2.ts ======*/
|
||||
|
||||
/**
|
||||
* @param {number} RENAME
|
||||
*/
|
||||
const foo = function foo([|RENAME|]) {
|
||||
return RENAME;
|
||||
}
|
||||
12
tests/cases/fourslash/renameFunctionParameter1.ts
Normal file
12
tests/cases/fourslash/renameFunctionParameter1.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////function Foo() {
|
||||
//// /**
|
||||
//// * @param {number} p
|
||||
//// */
|
||||
//// this.foo = function foo(p/**/) {
|
||||
//// return p;
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.baselineRename("", {});
|
||||
10
tests/cases/fourslash/renameFunctionParameter2.ts
Normal file
10
tests/cases/fourslash/renameFunctionParameter2.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
/////**
|
||||
//// * @param {number} p
|
||||
//// */
|
||||
////const foo = function foo(p/**/) {
|
||||
//// return p;
|
||||
////}
|
||||
|
||||
verify.baselineRename("", {});
|
||||
Reference in New Issue
Block a user