@@ -915,6 +915,9 @@ namespace ts.refactor.extractSymbol {
915915 if ( range . facts & RangeFacts . IsAsyncFunction ) {
916916 call = factory . createAwaitExpression ( call ) ;
917917 }
918+ if ( isInJSXContent ( node ) ) {
919+ call = factory . createJsxExpression ( /*dotDotDotToken*/ undefined , call ) ;
920+ }
918921
919922 if ( exposedVariableDeclarations . length && ! writes ) {
920923 // No need to mix declarations and writes.
@@ -1118,12 +1121,16 @@ namespace ts.refactor.extractSymbol {
11181121 variableType ,
11191122 initializer ) ;
11201123
1121- const localReference = factory . createPropertyAccessExpression (
1124+ let localReference : Expression = factory . createPropertyAccessExpression (
11221125 rangeFacts & RangeFacts . InStaticRegion
11231126 ? factory . createIdentifier ( scope . name ! . getText ( ) ) // TODO: GH#18217
11241127 : factory . createThis ( ) ,
11251128 factory . createIdentifier ( localNameText ) ) ;
11261129
1130+ if ( isInJSXContent ( node ) ) {
1131+ localReference = factory . createJsxExpression ( /*dotDotDotToken*/ undefined , localReference ) ;
1132+ }
1133+
11271134 // Declare
11281135 const maxInsertionPos = node . pos ;
11291136 const nodeToInsertBefore = getNodeToInsertPropertyBefore ( maxInsertionPos , scope ) ;
@@ -1194,12 +1201,6 @@ namespace ts.refactor.extractSymbol {
11941201 const renameLocation = getRenameLocation ( edits , renameFilename , localNameText , /*isDeclaredBeforeUse*/ true ) ;
11951202 return { renameFilename, renameLocation, edits } ;
11961203
1197- function isInJSXContent ( node : Node ) {
1198- if ( ! isJsxElement ( node ) ) return false ;
1199- if ( isJsxElement ( node . parent ) ) return true ;
1200- return false ;
1201- }
1202-
12031204 function transformFunctionInitializerAndType ( variableType : TypeNode | undefined , initializer : Expression ) : { variableType : TypeNode | undefined , initializer : Expression } {
12041205 // If no contextual type exists there is nothing to transfer to the function signature
12051206 if ( variableType === undefined ) return { variableType, initializer } ;
@@ -1953,4 +1954,8 @@ namespace ts.refactor.extractSymbol {
19531954 return false ;
19541955 }
19551956 }
1957+
1958+ function isInJSXContent ( node : Node ) {
1959+ return ( isJsxElement ( node ) || isJsxSelfClosingElement ( node ) || isJsxFragment ( node ) ) && isJsxElement ( node . parent ) ;
1960+ }
19561961}
0 commit comments