@@ -17,11 +17,9 @@ export function transformJsxMacros(
17
17
const asyncModifier = root . modifiers ?. find (
18
18
( modifier ) => modifier . kind === ts . SyntaxKind . AsyncKeyword ,
19
19
)
20
- let setup = `typeof ${ HELPER_PREFIX } setup`
21
- setup = asyncModifier ? `Awaited<${ setup } >` : setup
22
20
if ( asyncModifier && map . defineComponent )
23
21
replaceRange ( codes , asyncModifier . pos , asyncModifier . end )
24
- const result = `({}) as __VLS_PickNotAny<${ setup } [' render'] , {}> & { __ctx: ${ setup } }`
22
+ const result = `({}) as __VLS_PickNotAny<typeof ${ HELPER_PREFIX } ctx. render, {}> & { __ctx: typeof ${ HELPER_PREFIX } ctx }`
25
23
26
24
const propsType = root . parameters [ 0 ] ?. type
27
25
? String ( root . parameters [ 0 ] . type . getText ( ast ) )
@@ -31,16 +29,19 @@ export function transformJsxMacros(
31
29
root . parameters . pos ,
32
30
root . parameters . pos ,
33
31
ts . isArrowFunction ( root ) && root . parameters . pos === root . pos ? '(' : '' ,
34
- `${ HELPER_PREFIX } props: ${ setup } [' props'] & ${ propsType } , ` ,
32
+ `${ HELPER_PREFIX } props: typeof ${ HELPER_PREFIX } ctx. props & ${ propsType } , ` ,
35
33
`${ HELPER_PREFIX } placeholder?: {}, ` ,
34
+ `${ HELPER_PREFIX } ctx = {} as Awaited<ReturnType<typeof ${
35
+ HELPER_PREFIX
36
+ } setup>>, `,
36
37
`${ HELPER_PREFIX } setup = (${ asyncModifier ? 'async' : '' } (` ,
37
38
)
38
39
if ( ts . isArrowFunction ( root ) ) {
39
40
replaceRange (
40
41
codes ,
41
42
root . end ,
42
43
root . end ,
43
- `)() )${ root . pos === root . parameters . pos ? ')' : '' } => ` ,
44
+ `))${ root . pos === root . parameters . pos ? ')' : '' } => ` ,
44
45
result ,
45
46
)
46
47
} else {
@@ -50,7 +51,7 @@ export function transformJsxMacros(
50
51
root . body . getStart ( ast ) ,
51
52
'=>' ,
52
53
)
53
- replaceRange ( codes , root . end , root . end , `)() ){ return ` , result , '}' )
54
+ replaceRange ( codes , root . end , root . end , `)){ return ` , result , '}' )
54
55
}
55
56
56
57
ts . forEachChild ( root . body , ( node ) => {
0 commit comments