Skip to content

Commit 1a04fba

Browse files
committed
fix(compiler-sfc): infer object type for empty type literal
1 parent a94072d commit 1a04fba

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/compiler-sfc/src/compileScript.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,16 +2040,16 @@ function inferRuntimeType(
20402040
// TODO (nice to have) generate runtime property validation
20412041
const types = new Set<string>()
20422042
for (const m of node.members) {
2043-
switch (m.type) {
2044-
case 'TSCallSignatureDeclaration':
2045-
case 'TSConstructSignatureDeclaration':
2046-
types.add('Function')
2047-
break
2048-
default:
2049-
types.add('Object')
2043+
if (
2044+
m.type === 'TSCallSignatureDeclaration' ||
2045+
m.type === 'TSConstructSignatureDeclaration'
2046+
) {
2047+
types.add('Function')
2048+
} else {
2049+
types.add('Object')
20502050
}
20512051
}
2052-
return Array.from(types)
2052+
return types.size ? Array.from(types) : ['Object']
20532053
}
20542054
case 'TSFunctionType':
20552055
return ['Function']

0 commit comments

Comments
 (0)