Skip to content

Commit

Permalink
chore: Update returnsReactContent to handle varied JSX.Element or Rea…
Browse files Browse the repository at this point in the history
…ctPortal paths (#32)
  • Loading branch information
Rúben Carvalho authored Jan 12, 2024
1 parent 78ad9b2 commit 8c3fd50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/components-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function returnsReactContent(node: DeclarationReflection) {
return node.signatures?.some(
({ type }) =>
schema.types.isReferenceType(type) &&
(type.symbolFullyQualifiedName === 'global.JSX.Element' || type.symbolFullyQualifiedName === 'React.ReactPortal')
(type.symbolFullyQualifiedName.endsWith('JSX.Element') ||
type.symbolFullyQualifiedName.endsWith('React.ReactPortal'))
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/schema/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export function isOptionalDeclaration(prop: DeclarationReflection): boolean {
}

export function isForwardRefDeclaration({ type, name }: DeclarationReflection): boolean {
const isForwardRef = isReferenceType(type) && type.symbolFullyQualifiedName === 'React.ForwardRefExoticComponent';
const isForwardRef =
isReferenceType(type) && type.symbolFullyQualifiedName.endsWith('React.ForwardRefExoticComponent');
const isParametrizedForwardRef = Boolean(
isReferenceType(type) &&
type.name === `${name}ForwardRefType` &&
(type.reflection as DeclarationReflection | undefined)?.signatures?.some(({ name, type }) => {
return name === '__call' && isReferenceType(type) && type.symbolFullyQualifiedName === 'global.JSX.Element';
return name === '__call' && isReferenceType(type) && type.symbolFullyQualifiedName.endsWith('JSX.Element');
})
);
return isForwardRef || isParametrizedForwardRef;
Expand Down

0 comments on commit 8c3fd50

Please sign in to comment.