@@ -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' ;
@@ -448,27 +449,15 @@ function* generateComponentProps(
448
449
yield `}${ endOfLine } ` ;
449
450
}
450
451
451
- yield `type __VLS_PublicProps = ` ;
452
+ const propTypes : Code [ ] = [ ] ;
452
453
if ( scriptSetupRanges . defineSlots && options . vueCompilerOptions . jsxSlots ) {
453
- if ( ctx . generatedPropsType ) {
454
- yield ` & ` ;
455
- }
456
- ctx . generatedPropsType = true ;
457
- yield `${ ctx . localTypes . PropsChildren } <__VLS_Slots>` ;
454
+ propTypes . push ( `${ ctx . localTypes . PropsChildren } <__VLS_Slots>` ) ;
458
455
}
459
456
if ( scriptSetupRanges . defineProps ?. typeArg ) {
460
- if ( ctx . generatedPropsType ) {
461
- yield ` & ` ;
462
- }
463
- ctx . generatedPropsType = true ;
464
- yield `__VLS_Props` ;
457
+ propTypes . push ( `__VLS_Props` ) ;
465
458
}
466
459
if ( scriptSetupRanges . defineModel . length ) {
467
- if ( ctx . generatedPropsType ) {
468
- yield ` & ` ;
469
- }
470
- ctx . generatedPropsType = true ;
471
- yield `{${ newLine } ` ;
460
+ yield `type __VLS_ModelProps = {${ newLine } ` ;
472
461
for ( const defineModel of scriptSetupRanges . defineModel ) {
473
462
const [ propName , localName ] = getPropAndLocalName ( scriptSetup , defineModel ) ;
474
463
@@ -499,12 +488,15 @@ function* generateComponentProps(
499
488
yield `'${ modifierName } '?: Partial<Record<${ modifierType } , true>>,${ newLine } ` ;
500
489
}
501
490
}
502
- yield `}` ;
491
+ yield `}${ endOfLine } ` ;
492
+ propTypes . push ( `__VLS_ModelProps` ) ;
503
493
}
504
- if ( ! ctx . generatedPropsType ) {
505
- yield `{}` ;
494
+ if ( propTypes . length ) {
495
+ ctx . generatedPropsType = true ;
496
+ yield `type __VLS_PublicProps = ` ;
497
+ yield * generateIntersectMerge ( propTypes ) ;
498
+ yield endOfLine ;
506
499
}
507
- yield endOfLine ;
508
500
}
509
501
510
502
function * generateModelEmit (
0 commit comments