Let $f: (X, d_X) \rightarrow (Y, d_Y)$ be a function from metric spaces. If $f$ restricted to any compact subset of $X$ is continuous, then $f$ must be continuous everywhere.
Should I proceed with the characterization of continuity that the preimage of a closed set is closed? Except we are working with compact subsets of the domain, not the range, and it is not true that closed sets are mapped to closed sets, so how can I get continuity of $f$ everywhere?
I am also thinking about the fact that compactness is equivalent to sequential compactness in a metric space. Would this help?