Skip to content

Commit 4f6a6a4

Browse files
committed
fix: support null and any return type
1 parent b3c3e2a commit 4f6a6a4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

@plotly/dash-generator-test-component-typescript/src/components/WrappedHTML.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {WrappedHTMLProps} from '../props';
2+
import { WrappedHTMLProps } from '../props';
33

44
/**
55
* Component docstring

@plotly/dash-generator-test-component-typescript/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export {
1717
FCComponent,
1818
EmptyComponent,
1919
MixedComponent,
20-
RequiredChildrenComponent,
20+
RequiredChildrenComponent
2121
};

dash/extract-meta.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,14 @@ function gatherComponents(sources, components = {}) {
734734
return null
735735
}
736736

737-
// if (isArrowFunction) {
738-
// const signature = checker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];
739-
// const returnType = checker.typeToString(signature.getReturnType());
740-
// if (returnType !== 'Element') {
741-
// // Not JSX so no need to classifiy as compnent
742-
// return null;
743-
// }
744-
// }
737+
if (isArrowFunction) {
738+
const signature = checker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];
739+
const returnType = checker.typeToString(signature.getReturnType());
740+
if (!['Element', 'any', 'null'].includes(returnType)) {
741+
// Not JSX so no need to classifiy as compnent
742+
return null;
743+
}
744+
}
745745

746746
let defaultProps = getDefaultProps(typeSymbol, source);
747747
const propsType = getPropsForFunctionalComponent(type);

0 commit comments

Comments
 (0)