diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 562234a4305..23baadd0762 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13845,7 +13845,11 @@ namespace ts { } break; } - + + if (introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; location = location.parent; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a33419ae810..0847d1d7829 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -420,7 +420,10 @@ namespace ts { } export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) { - let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); + let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? + concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), + getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); return filter(commentRanges, isJsDocComment); function isJsDocComment(comment: CommentRange) { @@ -638,6 +641,20 @@ namespace ts { return false; } + export function introducesArgumentsExoticObject(node: Node) { + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + return true; + } + return false; + } + export function isFunctionBlock(node: Node) { return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent); } diff --git a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts new file mode 100644 index 00000000000..903253b1a09 --- /dev/null +++ b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts @@ -0,0 +1,22 @@ +/// + +////function testArguments() {/*1*/} +/////*2*/ +////function testNestedArguments() { +//// function nestedfunction(){/*3*/} +////} +////function f() { +//// let g = () => /*4*/ +////} +////let g = () => /*5*/ + +goTo.marker('1'); +verify.completionListContains("arguments"); +goTo.marker('2'); +verify.not.completionListContains("arguments"); +goTo.marker('3'); +verify.completionListContains("arguments"); +goTo.marker('4'); +verify.completionListContains("arguments"); +goTo.marker('5'); +verify.not.completionListContains("arguments"); \ No newline at end of file