Skip to content

Commit

Permalink
fix: api table error if function has no signature (#1853)
Browse files Browse the repository at this point in the history
* fix: api table error if function has no signature

* chore: update example
  • Loading branch information
PeachScript authored Aug 25, 2023
1 parent 77941aa commit 988a516
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/normal/src/Foo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const Foo: FC<{
children: React.ReactNode;
onConfirm: (output: { children: any[] }) => void;
dom: HTMLElement;
// eslint-disable-next-line @typescript-eslint/ban-types
func: Function;
}> = (props) => {
return <>{props.title}</>;
};
Expand Down
5 changes: 4 additions & 1 deletion src/client/theme-default/builtins/API/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ const HANDLERS = {
},
// FIXME: extract real type
function({ signature }: any) {
// handle Function type without signature
if (!signature) return 'Function';

const signatures = 'oneOf' in signature ? signature.oneOf : [signature];

return signatures
.map(
(signature) =>
(signature: any) =>
`${signature.isAsync ? 'async ' : ''}(${signature.arguments
.map((arg: any) => `${arg.key}: ${this.toString(arg)}`)
.join(', ')}) => ${this.toString(signature.returnType)}`,
Expand Down

0 comments on commit 988a516

Please sign in to comment.