Skip to content

Commit 00a0e3f

Browse files
committed
fix: fix extract to jsx component with zero props empty braces
1 parent 208e9a6 commit 00a0e3f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

typescript/src/codeActions/functionExtractors.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { equals } from 'rambda'
12
import { GetConfig } from '../types'
23
import {
34
createDummySourceFile,
@@ -113,10 +114,13 @@ export const handleFunctionRefactorEdits = (
113114
...textChanges.slice(0, -2),
114115
{
115116
...insertChange,
116-
newText: `<${componentName} ${args
117-
.split(', ')
118-
.map(identifierText => `${identifierText}={${identifierText}}`)
119-
.join(' ')} />`,
117+
newText: `<${componentName}${
118+
args &&
119+
` ${args
120+
.split(', ')
121+
.map(identifierText => `${identifierText}={${identifierText}}`)
122+
.join(' ')}`
123+
} />`,
120124
},
121125
{
122126
span: functionChange.span,

0 commit comments

Comments
 (0)