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: {
7777 node . range = [ node . start , node . end ]
7878 } ,
7979 enter ( node , parent ) {
80+ let tsNonNullExpressionEnd = 0
8081 if ( node . type === 'TSNonNullExpression' ) {
8182 node = node . expression
83+ tsNonNullExpressionEnd = node . end
8284 }
85+
8386 if ( node . type === 'CallExpression' ) {
8487 const calleeName = text . slice ( node . callee . start , node . callee . end )
8588 if ( calleeName === '$$' ) {
@@ -171,15 +174,15 @@ function transformReactivityFunction(options: {
171174 replaceSourceRange (
172175 codes ,
173176 source ,
174- node . end ,
175- node . end ,
177+ tsNonNullExpressionEnd || node . end ,
178+ tsNonNullExpressionEnd || node . end ,
176179 '\n,' ,
177180 ...toRefs . join ( '\n,' ) ,
178181 '\n,' ,
179182 `${ toValuesName } = ` ,
180183 parent . id . type === 'ArrayPattern' ? '[' : '{' ,
181- hasRest ? `...${ refName } ,` : '' ,
182- ...toValues . join ( '\n, ' ) ,
184+ hasRest ? `...${ refName } , ` : '' ,
185+ ...toValues . join ( ', ' ) ,
183186 parent . id . type === 'ArrayPattern' ? ']' : '}' ,
184187 '\n,' ,
185188 [
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ let __MACROS_ref0 = useApi(),
1616 id1 = toRef(__MACROS_ref0, 'id', 0),
1717 name = toRef(__MACROS_ref0, 'name'),
1818 rest1 = createPropsRestProxy(__MACROS_ref0, ['id', 'name']);
19- ;
2019id1.value == 0;
2120console.log({
2221 id1 : id1 .value ,
Original file line number Diff line number Diff line change @@ -9,24 +9,24 @@ function useApi$(defaultName = ref('')) {
99 }
1010}
1111
12- let { id : id1 = 0 , name, ...rest1 } = $useApi ( ) ;
13- ; id1 == 0
12+ let { id : id1 = 0 , name, ...rest1 } = $useApi ( ) !
13+ id1 == 0
1414console . log ( {
1515 id1,
1616 name,
17- rest1
17+ rest1,
1818} )
1919useApi$ ( name )
2020
2121function useArray$ ( ) {
2222 const foo = $ref ( 1 )
23- const bar = $ref ( 2 )
24- ; [ $$ ( foo ) , $$ ( bar ) ]
23+ const bar = $ref ( 2 )
24+ ; [ $$ ( foo ) , $$ ( bar ) ]
2525 return [ foo , bar ]
2626}
2727
2828let [ foo = 0 ] = $useArray ( )
29- foo === 1
29+ foo === 1
3030foo = 1
3131
3232// @ts -expect-error
@@ -36,14 +36,18 @@ console.log$(name)
3636watch$ ( name , ( ) => {
3737 let name = 1
3838 return {
39- name
39+ name,
4040 }
4141} )
4242
4343defineExpose$ ( {
4444 name,
45- } )
46- const title = $ref < string > ( 'title' )
45+ } )
46+ const title = $ref < string > ( 'title' )
4747console . 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