@@ -37,6 +37,18 @@ function isSupportedDefinitionType({node}) {
3737 types . ClassDeclaration . check ( node ) ||
3838 types . ClassExpression . check ( node ) ||
3939
40+ /**
41+ * Adds support for libraries such as
42+ * [styled components]{@link https://github.com/styled-components} that use
43+ * TaggedTemplateExpression's to generate components.
44+ *
45+ * While react-docgen's built-in resolvers do not support resolving
46+ * TaggedTemplateExpression definitiona, third-party resolvers (such as
47+ * https://github.com/Jmeyering/react-docgen-annotation-resolver) could be
48+ * used to add these definitions.
49+ */
50+ types . TaggedTemplateExpression . check ( node ) ||
51+
4052 // potential stateless function component
4153 types . VariableDeclaration . check ( node ) ||
4254 types . ArrowFunctionExpression . check ( node ) ||
@@ -65,13 +77,14 @@ export default function getMemberValuePath(
6577 throw new TypeError (
6678 'Got unsupported definition type. Definition must be one of ' +
6779 'ObjectExpression, ClassDeclaration, ClassExpression,' +
68- 'VariableDeclaration, ArrowFunctionExpression, FunctionExpression, or ' +
69- 'FunctionDeclaration. Got "' + componentDefinition . node . type + ' "' +
70- 'instead.'
80+ 'VariableDeclaration, ArrowFunctionExpression, FunctionExpression, ' +
81+ 'TaggedTemplateExpression or FunctionDeclaration. Got "' +
82+ componentDefinition . node . type + '"' + 'instead.'
7183 ) ;
7284 }
7385
74- var lookupMethod = LOOKUP_METHOD [ componentDefinition . node . type ] ;
86+ var lookupMethod = LOOKUP_METHOD [ componentDefinition . node . type ]
87+ || getMemberExpressionValuePath ;
7588 var result = lookupMethod ( componentDefinition , memberName ) ;
7689 if ( ! result && SYNONYMS [ memberName ] ) {
7790 return lookupMethod ( componentDefinition , SYNONYMS [ memberName ] ) ;
0 commit comments