Skip to content

Commit

Permalink
fix(compiler-sfc): infer runtime type in defineProps (vuejs#7972)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored and IAmSSH committed Apr 29, 2023
1 parent 1b243a2 commit 93fab81
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ function inferRuntimeType(
case 'BigIntLiteral':
return ['Number']
default:
return [`UNKNOWN`]
return [UNKNOWN_TYPE]
}

case 'TSTypeReference':
Expand Down Expand Up @@ -2177,13 +2177,15 @@ function inferRuntimeType(
declaredTypes
).filter(t => t !== 'null')
}
break
case 'Extract':
if (node.typeParameters && node.typeParameters.params[1]) {
return inferRuntimeType(
node.typeParameters.params[1],
declaredTypes
)
}
break
case 'Exclude':
case 'OmitThisParameter':
if (node.typeParameters && node.typeParameters.params[0]) {
Expand All @@ -2192,9 +2194,10 @@ function inferRuntimeType(
declaredTypes
)
}
// cannot infer, fallback to UNKNOWN: ThisParameterType
break
}
}
// cannot infer, fallback to UNKNOWN: ThisParameterType
return [UNKNOWN_TYPE]

case 'TSParenthesizedType':
Expand Down

0 comments on commit 93fab81

Please sign in to comment.