From 33ec4ac6f7436be97fe52a975fe3271cc3865208 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Mon, 11 Apr 2022 11:14:30 +0100 Subject: [PATCH] fix(storybook): component props should only consider inputs #9417 (#9780) Previously, all decorators were being taken into consideration. However, props to an Angular component would be its Inputs. We should only consider those. Fixes #9417 --- packages/angular/src/generators/utils/storybook.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/angular/src/generators/utils/storybook.ts b/packages/angular/src/generators/utils/storybook.ts index 023dec51e3fcd..fa7f668268ad6 100644 --- a/packages/angular/src/generators/utils/storybook.ts +++ b/packages/angular/src/generators/utils/storybook.ts @@ -41,11 +41,15 @@ export function getComponentProps( const props = getInputPropertyDeclarations(tree, componentPath).map( (node) => { const decoratorContent = findNodes( - findNodes(node, SyntaxKind.Decorator)[0], + findNodes(node, SyntaxKind.Decorator).find((n) => + n.getText().startsWith('@Input') + ), SyntaxKind.StringLiteral ); const name = decoratorContent.length - ? decoratorContent[0].getText().slice(1, -1) + ? !decoratorContent[0].getText().includes('.') + ? decoratorContent[0].getText().slice(1, -1) + : node.name.getText() : node.name.getText(); const type = getKnobType(node);