After calling creep.transfer(...) the operation is just scheduled to be executed at the current tick (see engine descriptions, http://support.screeps.com/hc/en-us/articles/203032752-Understanding-game-loop-time-and-ticks), so inner states of all objects wont change until next tick.
Seems like the workaround (without exact amount specifying, 3rd argument) looks like:
let result = creep.transfer(obj, resource);let transferred = result === OK ? Math.min(creep.carry[resource], /*obj.emptySpace*/) : 0;
Dunno why u gonna do that, looks monstrous