File tree Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -77,9 +77,12 @@ function transformReactivityFunction(options: {
77
77
node . range = [ node . start , node . end ]
78
78
} ,
79
79
enter ( node , parent ) {
80
+ let tsNonNullExpressionEnd = 0
80
81
if ( node . type === 'TSNonNullExpression' ) {
81
82
node = node . expression
83
+ tsNonNullExpressionEnd = node . end
82
84
}
85
+
83
86
if ( node . type === 'CallExpression' ) {
84
87
const calleeName = text . slice ( node . callee . start , node . callee . end )
85
88
if ( calleeName === '$$' ) {
@@ -171,15 +174,15 @@ function transformReactivityFunction(options: {
171
174
replaceSourceRange (
172
175
codes ,
173
176
source ,
174
- node . end ,
175
- node . end ,
177
+ tsNonNullExpressionEnd || node . end ,
178
+ tsNonNullExpressionEnd || node . end ,
176
179
'\n,' ,
177
180
...toRefs . join ( '\n,' ) ,
178
181
'\n,' ,
179
182
`${ toValuesName } = ` ,
180
183
parent . id . type === 'ArrayPattern' ? '[' : '{' ,
181
- hasRest ? `...${ refName } ,` : '' ,
182
- ...toValues . join ( '\n, ' ) ,
184
+ hasRest ? `...${ refName } , ` : '' ,
185
+ ...toValues . join ( ', ' ) ,
183
186
parent . id . type === 'ArrayPattern' ? ']' : '}' ,
184
187
'\n,' ,
185
188
[
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ let __MACROS_ref0 = useApi(),
16
16
id1 = toRef(__MACROS_ref0, 'id', 0),
17
17
name = toRef(__MACROS_ref0, 'name'),
18
18
rest1 = createPropsRestProxy(__MACROS_ref0, ['id', 'name']);
19
- ;
20
19
id1.value == 0;
21
20
console.log({
22
21
id1 : id1 .value ,
Original file line number Diff line number Diff line change @@ -9,24 +9,24 @@ function useApi$(defaultName = ref('')) {
9
9
}
10
10
}
11
11
12
- let { id : id1 = 0 , name, ...rest1 } = $useApi ( ) ;
13
- ; id1 == 0
12
+ let { id : id1 = 0 , name, ...rest1 } = $useApi ( ) !
13
+ id1 == 0
14
14
console . log ( {
15
15
id1,
16
16
name,
17
- rest1
17
+ rest1,
18
18
} )
19
19
useApi$ ( name )
20
20
21
21
function useArray$ ( ) {
22
22
const foo = $ref ( 1 )
23
- const bar = $ref ( 2 )
24
- ; [ $$ ( foo ) , $$ ( bar ) ]
23
+ const bar = $ref ( 2 )
24
+ ; [ $$ ( foo ) , $$ ( bar ) ]
25
25
return [ foo , bar ]
26
26
}
27
27
28
28
let [ foo = 0 ] = $useArray ( )
29
- foo === 1
29
+ foo === 1
30
30
foo = 1
31
31
32
32
// @ts -expect-error
@@ -36,14 +36,18 @@ console.log$(name)
36
36
watch$ ( name , ( ) => {
37
37
let name = 1
38
38
return {
39
- name
39
+ name,
40
40
}
41
41
} )
42
42
43
43
defineExpose$ ( {
44
44
name,
45
- } )
46
- const title = $ref < string > ( 'title' )
45
+ } )
46
+ const title = $ref < string > ( 'title' )
47
47
console . log ( $$ ( title ) )
48
- const Comp = ( { title } : { title : Ref < string > , foo : string } ) => title . value
49
- export default ( ) => < Comp title$ = { title } foo = { title } > { title } </ Comp >
48
+ const Comp = ( { title } : { title : Ref < string > ; foo : string } ) => title . value
49
+ export default ( ) => (
50
+ < Comp title$ = { title } foo = { title } >
51
+ { title }
52
+ </ Comp >
53
+ )
You can’t perform that action at this time.
0 commit comments