From 11f589f03b87d8e52371fc9cca1e680eb16de17e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 22 Feb 2015 15:06:58 -0800 Subject: [PATCH] do not include constructor parameters with binding patterns as names when collecting nav bar items --- src/services/navigationBar.ts | 4 ++-- ...LexicalStructureBindingPatternsInConstructor.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index b254397f8b0cc..e32ac03caef95 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -423,11 +423,11 @@ module ts.NavigationBar { }); // Add the constructor parameters in as children of the class (for property parameters). - // Note that *all* parameters will be added to the nodes array, but parameters that + // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that // are not properties will be filtered out later by createChildItem. var nodes: Node[] = removeDynamicallyNamedProperties(node); if (constructor) { - nodes.push.apply(nodes, constructor.parameters); + nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name))); } var childItems = getItemsWorker(sortNodes(nodes), createChildItem); diff --git a/tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts b/tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts new file mode 100644 index 0000000000000..c496a0281e3a1 --- /dev/null +++ b/tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts @@ -0,0 +1,14 @@ +/// + +////class A { +//// x: any +//// constructor([a]: any) { +//// } +////} +////class B { +//// x: any; +//// constructor( {a} = { a: 1 }) { +//// } +////} + +verify.getScriptLexicalStructureListCount(6); // 2x(class + field + constructor)