From 77d8ee47f52eb43e2c1fdf30a3d39ab8d04ef2dc Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 22 Dec 2022 11:45:53 +0200 Subject: [PATCH] fix(storybook): optional-chain typeName (#13951) --- packages/react/src/utils/ast-utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react/src/utils/ast-utils.ts b/packages/react/src/utils/ast-utils.ts index c798f03916..2ebfa55956 100644 --- a/packages/react/src/utils/ast-utils.ts +++ b/packages/react/src/utils/ast-utils.ts @@ -629,7 +629,7 @@ export function getComponentPropsInterface( (x) => ts.isParameter(x) && (x.name as ts.Identifier).text === 'props' ); - if (propsParam && propsParam.type) { + if (propsParam?.type?.['typeName']) { propsTypeName = ( (propsParam.type as ts.TypeReferenceNode).typeName as ts.Identifier ).text; @@ -666,10 +666,10 @@ export function getComponentPropsInterface( return name === 'Component' || name === 'PureComponent'; }); - if (propsTypeExpression && propsTypeExpression.typeArguments) { + if (propsTypeExpression?.typeArguments?.[0]?.['typeName']) { propsTypeName = ( propsTypeExpression.typeArguments[0] as ts.TypeReferenceNode - ).typeName?.getText(); + ).typeName.getText(); } } } else {