From d61c4d2aee9e96a3d0f2fef6105f86db5e42e758 Mon Sep 17 00:00:00 2001 From: SimplyY <8455579+SimplyY@users.noreply.github.com> Date: Thu, 24 Sep 2020 10:03:14 +0800 Subject: [PATCH] fix: fix when initializer is undefined related issue: https://github.com/styleguidist/react-docgen-typescript/issues/301 --- src/parser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/parser.ts b/src/parser.ts index 9f656db2..4ebb0c5d 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -793,6 +793,9 @@ export class Parser { const defaultProps = possibleDefaultProps[0]; let initializer = (defaultProps as ts.PropertyDeclaration).initializer; + if (!initializer) { + return res; + } let properties = (initializer as ts.ObjectLiteralExpression).properties; while (ts.isIdentifier(initializer as ts.Identifier)) {