mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): infer object type for empty type literal
This commit is contained in:
parent
a94072dd2c
commit
1a04fba10b
|
|
@ -2040,16 +2040,16 @@ function inferRuntimeType(
|
||||||
// TODO (nice to have) generate runtime property validation
|
// TODO (nice to have) generate runtime property validation
|
||||||
const types = new Set<string>()
|
const types = new Set<string>()
|
||||||
for (const m of node.members) {
|
for (const m of node.members) {
|
||||||
switch (m.type) {
|
if (
|
||||||
case 'TSCallSignatureDeclaration':
|
m.type === 'TSCallSignatureDeclaration' ||
|
||||||
case 'TSConstructSignatureDeclaration':
|
m.type === 'TSConstructSignatureDeclaration'
|
||||||
|
) {
|
||||||
types.add('Function')
|
types.add('Function')
|
||||||
break
|
} else {
|
||||||
default:
|
|
||||||
types.add('Object')
|
types.add('Object')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Array.from(types)
|
return types.size ? Array.from(types) : ['Object']
|
||||||
}
|
}
|
||||||
case 'TSFunctionType':
|
case 'TSFunctionType':
|
||||||
return ['Function']
|
return ['Function']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue