@@ -31,7 +31,7 @@ export function* generateComponent(
31
31
yield `}${ endOfLine } ` ;
32
32
yield `},${ newLine } ` ;
33
33
if ( ! ctx . bypassDefineComponent ) {
34
- yield * generateScriptSetupOptions ( options , ctx , scriptSetup , scriptSetupRanges ) ;
34
+ yield * generateScriptSetupOptions ( options , ctx , scriptSetup , scriptSetupRanges , true ) ;
35
35
}
36
36
if ( options . sfc . script && options . scriptRanges ) {
37
37
yield * generateScriptOptions ( options . sfc . script , options . scriptRanges ) ;
@@ -65,24 +65,42 @@ export function* generateScriptSetupOptions(
65
65
options : ScriptCodegenOptions ,
66
66
ctx : ScriptCodegenContext ,
67
67
scriptSetup : NonNullable < Sfc [ 'scriptSetup' ] > ,
68
- scriptSetupRanges : ScriptSetupRanges
68
+ scriptSetupRanges : ScriptSetupRanges ,
69
+ inheritAttrs : boolean
69
70
) : Generator < Code > {
70
- yield * generatePropsOption ( options , ctx , scriptSetup , scriptSetupRanges ) ;
71
+ yield * generatePropsOption ( options , ctx , scriptSetup , scriptSetupRanges , inheritAttrs ) ;
71
72
yield * generateEmitsOption ( options , scriptSetup , scriptSetupRanges ) ;
72
73
}
73
74
74
75
export function * generatePropsOption (
75
76
options : ScriptCodegenOptions ,
76
77
ctx : ScriptCodegenContext ,
77
78
scriptSetup : NonNullable < Sfc [ 'scriptSetup' ] > ,
78
- scriptSetupRanges : ScriptSetupRanges
79
+ scriptSetupRanges : ScriptSetupRanges ,
80
+ inheritAttrs : boolean
79
81
) {
80
- if ( options . vueCompilerOptions . target >= 3.5 && ctx . generatedPropsType ) {
81
- yield `__typeProps: {} as __VLS_PublicProps,${ newLine } ` ;
82
+
83
+ if ( options . vueCompilerOptions . target >= 3.5 ) {
84
+ const types = [ ] ;
85
+ if ( inheritAttrs && options . templateCodegen ?. inheritedAttrVars . size ) {
86
+ types . push ( 'typeof __VLS_template>[1]' ) ;
87
+ }
88
+ if ( ctx . generatedPropsType ) {
89
+ types . push ( '{} as __VLS_PublicProps' ) ;
90
+ }
91
+ if ( types . length ) {
92
+ yield `__typeProps: ${ types . join ( ' & ' ) } ,${ newLine } ` ;
93
+ }
82
94
}
83
95
if ( options . vueCompilerOptions . target < 3.5 || ! ctx . generatedPropsType || scriptSetupRanges . props . withDefaults ) {
84
96
const codegens : ( ( ) => Generator < Code > ) [ ] = [ ] ;
85
97
98
+ if ( inheritAttrs && options . templateCodegen ?. inheritedAttrVars . size ) {
99
+ codegens . push ( function * ( ) {
100
+ yield `{} as ${ ctx . helperTypes . TypePropsToOption . name } <__VLS_PickNotAny<${ ctx . helperTypes . OmitIndexSignature . name } <ReturnType<typeof __VLS_template>[1]>, {}>>` ;
101
+ } ) ;
102
+ }
103
+
86
104
if ( ctx . generatedPropsType ) {
87
105
codegens . push ( function * ( ) {
88
106
yield `{} as ` ;
0 commit comments