@@ -4,6 +4,7 @@ import type { Code, Sfc, TextRange } from '../../types';
4
4
import { codeFeatures } from '../codeFeatures' ;
5
5
import { endOfLine , generateSfcBlockSection , identifierRegex , newLine } from '../utils' ;
6
6
import { generateCamelized } from '../utils/camelized' ;
7
+ import { generateIntersectMerge } from '../utils/merge' ;
7
8
import { wrapWith } from '../utils/wrapWith' ;
8
9
import { generateComponent } from './component' ;
9
10
import type { ScriptCodegenContext } from './context' ;
@@ -451,27 +452,15 @@ function* generateComponentProps(
451
452
yield `}${ endOfLine } ` ;
452
453
}
453
454
454
- yield `type __VLS_PublicProps = ` ;
455
+ const propTypes : Code [ ] = [ ] ;
455
456
if ( scriptSetupRanges . defineSlots && options . vueCompilerOptions . jsxSlots ) {
456
- if ( ctx . generatedPropsType ) {
457
- yield ` & ` ;
458
- }
459
- ctx . generatedPropsType = true ;
460
- yield `${ ctx . localTypes . PropsChildren } <__VLS_Slots>` ;
457
+ propTypes . push ( `${ ctx . localTypes . PropsChildren } <__VLS_Slots>` ) ;
461
458
}
462
459
if ( scriptSetupRanges . defineProps ?. typeArg ) {
463
- if ( ctx . generatedPropsType ) {
464
- yield ` & ` ;
465
- }
466
- ctx . generatedPropsType = true ;
467
- yield `__VLS_Props` ;
460
+ propTypes . push ( `__VLS_Props` ) ;
468
461
}
469
462
if ( scriptSetupRanges . defineModel . length ) {
470
- if ( ctx . generatedPropsType ) {
471
- yield ` & ` ;
472
- }
473
- ctx . generatedPropsType = true ;
474
- yield `{${ newLine } ` ;
463
+ yield `type __VLS_ModelProps = {${ newLine } ` ;
475
464
for ( const defineModel of scriptSetupRanges . defineModel ) {
476
465
const [ propName , localName ] = getPropAndLocalName ( scriptSetup , defineModel ) ;
477
466
@@ -502,12 +491,15 @@ function* generateComponentProps(
502
491
yield `'${ modifierName } '?: Partial<Record<${ modifierType } , true>>,${ newLine } ` ;
503
492
}
504
493
}
505
- yield `}` ;
494
+ yield `}${ endOfLine } ` ;
495
+ propTypes . push ( `__VLS_ModelProps` ) ;
506
496
}
507
- if ( ! ctx . generatedPropsType ) {
508
- yield `{}` ;
497
+ if ( propTypes . length ) {
498
+ ctx . generatedPropsType = true ;
499
+ yield `type __VLS_PublicProps = ` ;
500
+ yield * generateIntersectMerge ( propTypes ) ;
501
+ yield endOfLine ;
509
502
}
510
- yield endOfLine ;
511
503
}
512
504
513
505
function * generateModelEmit (
0 commit comments