File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,13 @@ function insertElement(
29
29
) : void {
30
30
if ( typeof data === 'string' ) {
31
31
const existingLiterals = ast . elements . filter ( ( x ) => x ?. type === 'StringLiteral' ) ;
32
- const literal = existingLiterals . find ( ( x ) => x . value === data ) ?? {
33
- type : 'StringLiteral' ,
34
- value : data
35
- } ;
32
+ let literal = existingLiterals . find ( ( x ) => x . value === data ) ;
33
+ if ( ! literal ) {
34
+ literal = { type : 'StringLiteral' , value : data } ;
36
35
37
- if ( insertEnd ) ast . elements . push ( literal ) ;
38
- else ast . elements . unshift ( literal ) ;
36
+ if ( insertEnd ) ast . elements . push ( literal ) ;
37
+ else ast . elements . unshift ( literal ) ;
38
+ }
39
39
} else {
40
40
const elements = ast . elements as AstTypes . ASTNode [ ] ;
41
41
const anyNodeEquals = elements . some ( ( node ) => areNodesEqual ( data , node ) ) ;
You can’t perform that action at this time.
0 commit comments