In the StructureSpawn description (http://support.screeps.com/hc/en-us/articles/205990342-StructureSpawn) the declaration of this functino is not requiring the resource type, but instead the amount (which is optional)
transferEnergy(target, [amount])
Interestingly enough the function still returns -9 in case the creep is too far away, which is why it moves.
Anyway as far as i know, The constant RESOURCE_ENERGY resolves to the string "energy", so when the creep arrives at the spawn, it does not know how to transfer "energy" units of energy to the creep. You could add an else bracket to check for other error codes returning, but if you go for Game.spawns.Spawn1.transferEnergy(creep), everything should be fine.