@@ -513,22 +513,27 @@ export function compileScript(
513
513
)
514
514
}
515
515
516
- function genRuntimeProps ( props : Record < string , PropTypeData > ) {
517
- const keys = Object . keys ( props )
518
- if ( ! keys . length ) {
519
- return ``
520
- }
521
-
522
- // check defaults. If the default object is an object literal with only
523
- // static properties, we can directly generate more optimzied default
524
- // decalrations. Otherwise we will have to fallback to runtime merging.
525
- const hasStaticDefaults =
516
+ /**
517
+ * check defaults. If the default object is an object literal with only
518
+ * static properties, we can directly generate more optimzied default
519
+ * decalrations. Otherwise we will have to fallback to runtime merging.
520
+ */
521
+ function checkStaticDefaults ( ) {
522
+ return (
526
523
propsRuntimeDefaults &&
527
524
propsRuntimeDefaults . type === 'ObjectExpression' &&
528
525
propsRuntimeDefaults . properties . every (
529
526
node => node . type === 'ObjectProperty' && ! node . computed
530
527
)
528
+ )
529
+ }
531
530
531
+ function genRuntimeProps ( props : Record < string , PropTypeData > ) {
532
+ const keys = Object . keys ( props )
533
+ if ( ! keys . length ) {
534
+ return ``
535
+ }
536
+ const hasStaticDefaults = checkStaticDefaults ( )
532
537
let propsDecls = `{
533
538
${ keys
534
539
. map ( key => {
@@ -580,12 +585,7 @@ export function compileScript(
580
585
if ( ! keys . length ) {
581
586
return ``
582
587
}
583
- const hasStaticDefaults =
584
- propsRuntimeDefaults &&
585
- propsRuntimeDefaults . type === 'ObjectExpression' &&
586
- propsRuntimeDefaults . properties . every (
587
- node => node . type === 'ObjectProperty' && ! node . computed
588
- )
588
+ const hasStaticDefaults = checkStaticDefaults ( )
589
589
keys . map ( key => {
590
590
if ( hasStaticDefaults ) {
591
591
const prop = ( propsRuntimeDefaults as ObjectExpression ) . properties . find (
0 commit comments