I don't really know about the gigafactory, but it seems logic that a % of it is dedicated to R&D and growth. Plus, this battery tech doesn't create itself, if I remember reading correctly Tesla is making some advancements in here as well.
I think the error in this thinking is in assuming that the market leader will be the source of the next step change in innovation. This is covered very well in the book "The Innovator's Dilemma". Bottom line, this is seldom the case. If the inflection point in battery technology comes from an outfit Tesla does not control they could be in trouble. All other car manufacturers will simply go off and buy these new better batteries while Tesla will have to figure out what to do with a factory that can't produce them and, perhaps, never will because they won't have command of the tech.
On the other hand, I'd guess there's a "small" window of a couple of years for a real breakthrough+production outside of Tesla to affect them. Seeing the history of batteries and incremental improvements for the last 20? years, it'd be pretty rare for it to happen now.