@@ -528,9 +528,9 @@ class JSGenerator {
528528 case 'json.valueOfKey' :
529529 return new TypedInput ( `(${ this . descendInput ( node . object ) . asObject ( ) } [${ this . descendInput ( node . key ) . asString ( ) } ] ?? "")` , TYPE_STRING ) ;
530530 case 'json.setKey' :
531- return new TypedInput ( `(object = ${ this . descendInput ( node . object ) . asObject ( ) } , object[${ this . descendInput ( node . key ) . asString ( ) } ] = ${ this . descendInput ( node . value ) . asString ( ) } , object)` , TYPE_OBJECT ) ;
531+ return new TypedInput ( `(object = {... ${ this . descendInput ( node . object ) . asObject ( ) } } , object[${ this . descendInput ( node . key ) . asString ( ) } ] = ${ this . descendInput ( node . value ) . asUnknown ( ) } , object)` , TYPE_OBJECT ) ;
532532 case 'json.deleteKey' :
533- return new TypedInput ( `(object = ${ this . descendInput ( node . object ) . asObject ( ) } , delete object[${ this . descendInput ( node . key ) . asString ( ) } ], object)` , TYPE_OBJECT ) ;
533+ return new TypedInput ( `(object = {... ${ this . descendInput ( node . object ) . asObject ( ) } }, delete object[${ this . descendInput ( node . key ) . asString ( ) } ], object)` , TYPE_OBJECT ) ;
534534 case 'json.mergeObject' :
535535 return new TypedInput ( `{...${ this . descendInput ( node . object1 ) . asObject ( ) } , ...${ this . descendInput ( node . object2 ) . asObject ( ) } }` , TYPE_OBJECT ) ;
536536 case 'json.hasKey' :
@@ -542,19 +542,19 @@ class JSGenerator {
542542 case 'json.valueOfIndex' :
543543 return new TypedInput ( `(${ this . descendInput ( node . array ) . asArray ( ) } [${ this . descendInput ( node . index ) . asNumber ( ) } ] ?? "")` , TYPE_STRING ) ;
544544 case 'json.indexOfValue' :
545- return new TypedInput ( `(${ this . descendInput ( node . array ) . asArray ( ) } .indexOf(${ this . descendInput ( node . value ) . asString ( ) } ) !== -1 ? ${ this . descendInput ( node . array ) . asArray ( ) } .indexOf(${ this . descendInput ( node . value ) . asString ( ) } ) : "")` , TYPE_STRING ) ;
545+ return new TypedInput ( `(${ this . descendInput ( node . array ) . asArray ( ) } .indexOf(${ this . descendInput ( node . value ) . asUnknown ( ) } ) !== -1 ? ${ this . descendInput ( node . array ) . asArray ( ) } .indexOf(${ this . descendInput ( node . value ) . asUnknown ( ) } ) : "")` , TYPE_NUMBER ) ;
546546 case 'json.addItem' :
547- return new TypedInput ( `(array = ${ this . descendInput ( node . array ) . asArray ( ) } , array.push(${ this . descendInput ( node . item ) . asString ( ) } ), array)` , TYPE_ARRAY ) ;
547+ return new TypedInput ( `(array = [... ${ this . descendInput ( node . array ) . asArray ( ) } ] , array.push(${ this . descendInput ( node . item ) . asUnknown ( ) } ), array)` , TYPE_ARRAY ) ;
548548 case 'json.replaceIndex' :
549- return new TypedInput ( `(${ this . descendInput ( node . index ) . asNumber ( ) } >= 0 && ${ this . descendInput ( node . index ) . asNumber ( ) } < ${ this . descendInput ( node . array ) . asArray ( ) } .length ? (array = ${ this . descendInput ( node . array ) . asArray ( ) } , array[${ this . descendInput ( node . index ) . asNumber ( ) } ] = ${ this . descendInput ( node . item ) . asString ( ) } , array) : new Array())` , TYPE_ARRAY ) ;
549+ return new TypedInput ( `(${ this . descendInput ( node . index ) . asNumber ( ) } >= 0 && ${ this . descendInput ( node . index ) . asNumber ( ) } < ${ this . descendInput ( node . array ) . asArray ( ) } .length ? (array = [... ${ this . descendInput ( node . array ) . asArray ( ) } ] , array[${ this . descendInput ( node . index ) . asNumber ( ) } ] = ${ this . descendInput ( node . item ) . asUnknown ( ) } , array) : new Array())` , TYPE_ARRAY ) ;
550550 case 'json.deleteIndex' :
551- return new TypedInput ( `(${ this . descendInput ( node . index ) . asNumber ( ) } >= 0 && ${ this . descendInput ( node . index ) . asNumber ( ) } < ${ this . descendInput ( node . array ) . asArray ( ) } .length ? (array = ${ this . descendInput ( node . array ) . asArray ( ) } , array.splice(${ this . descendInput ( node . index ) . asNumber ( ) } , 1), array) : new Array())` , TYPE_ARRAY ) ;
551+ return new TypedInput ( `(${ this . descendInput ( node . index ) . asNumber ( ) } >= 0 && ${ this . descendInput ( node . index ) . asNumber ( ) } < ${ this . descendInput ( node . array ) . asArray ( ) } .length ? (array = [... ${ this . descendInput ( node . array ) . asArray ( ) } ] , array.splice(${ this . descendInput ( node . index ) . asNumber ( ) } , 1), array) : new Array())` , TYPE_ARRAY ) ;
552552 case 'json.deleteAllOccurrences' :
553553 return new TypedInput ( `${ this . descendInput ( node . array ) . asArray ( ) } .filter((item) => item !== ${ this . descendInput ( node . item ) . asString ( ) } )` , TYPE_ARRAY ) ;
554554 case 'json.mergeArray' :
555555 return new TypedInput ( `[...${ this . descendInput ( node . array1 ) . asArray ( ) } , ...${ this . descendInput ( node . array2 ) . asArray ( ) } ]` , TYPE_ARRAY ) ;
556556 case 'json.hasItem' :
557- return new TypedInput ( `${ this . descendInput ( node . array ) . asArray ( ) } .includes(${ this . descendInput ( node . item ) . asString ( ) } )` , TYPE_BOOLEAN ) ;
557+ return new TypedInput ( `${ this . descendInput ( node . array ) . asArray ( ) } .includes(${ this . descendInput ( node . item ) . asUnknown ( ) } )` , TYPE_BOOLEAN ) ;
558558
559559 case 'looks.size' :
560560 return new TypedInput ( 'Math.round(target.size)' , TYPE_NUMBER ) ;
0 commit comments