Skip to content

Commit d6cb748

Browse files
committed
fix(complex-types): handle function correctly
1 parent 2a49997 commit d6cb748

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/complex-types/src/core/printer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ export class Printer {
5959
if (this.typeToString(type).endsWith("[]")) {
6060
return this.typeToString(type);
6161
} else if (type.flags & ts.TypeFlags.Object) {
62+
const decl = type.getSymbol()?.declarations?.[0];
63+
if (decl && ts.isFunctionTypeNode(decl)) {
64+
return "Function";
65+
}
66+
6267
if (inner) {
6368
return "object";
6469
}
70+
6571
const properties = type.getProperties();
6672
const props: Record<
6773
string,

packages/complex-types/test/__snapshots__/fixtures-compiled.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
123123
required: true
124124
},
125125
function: {
126-
type: Object,
126+
type: Function,
127127
required: true
128128
},
129129
error: {

packages/complex-types/test/__snapshots__/fixtures.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defineProps<
5050
"array": string[],
5151
"genericArray": (string | number)[],
5252
"genericCondition": string | number,
53-
"function": object,
53+
"function": Function,
5454
"error": object,
5555
"null": null | string,
5656
} & {

0 commit comments

Comments
 (0)