diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fe6cbee6cbb..23baadd0762 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13809,7 +13809,7 @@ namespace ts { if (location.locals && !isGlobalSourceFile(location)) { copySymbols(location.locals, meaning); } - + switch (location.kind) { case SyntaxKind.SourceFile: if (!isExternalModule(location)) { @@ -13845,9 +13845,11 @@ namespace ts { } break; } - if (isFunctionLike(location)) { + + 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 index 2ef851513f3..903253b1a09 100644 --- a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts +++ b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts @@ -5,10 +5,18 @@ ////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"); \ No newline at end of file +verify.completionListContains("arguments"); +goTo.marker('4'); +verify.completionListContains("arguments"); +goTo.marker('5'); +verify.not.completionListContains("arguments"); \ No newline at end of file