tower.pos.findClosestByRange(STRUCTURE_RAMPART, { filter: (structuere) => structure.hits < 30000 });
Maybe just replace "structuere" by "structure" I use this :
room.find( FIND_STRUCTURES, { filter: ( f ) => { return ( f.hits < f.hitsMax )}}).sort( function( a, b ) { return +a.hits - +b.hits })[ 0 ]