This theorem does not follow in a straightforward way from Mergelyan's theorem, which on its face applies only to bounded domains.

There is, however, a related theorem called Arakelian's theorem which settles the matter. For completeness:

**Definition**: A "hole" of a closed subset $E$ of $\mathbb{C}$ is any bounded component of the complement of $E$.

**Definition** A set $E$ is Arakelian if $E$ has no holes, and if for every closed disk $D$, the union of all holes of $E \cup D$ is bounded.

**Theorem** Let $E$ be Arakelian. If $f$ is continuous on $E$ and holomorphic on the interior of $E$, then $f$ can be uniformly approximated by entire functions.

A proof deriving this result from Mergelyan's theorem can be found here.

I would also like to remark that Mergelyan's theorem (while usually stated for polynomial approximation) actually applies to domains with holes as well, if you just allow rational approximation with "poles in the holes".

I would also like to draw attention to how crazy Mergelyan's theorem is. One consequence is that one can approximate an antiholomorphic function by entire functions on any set without interior. For instance, one can approximate $\overline{z}$ on the "plus sign" consisting on the interval $[-1,1]$ on the real axis and "$[-i,i]$" on the imaginary axis. If anyone can explicitly construct such approximating functions, I would be very happy to see them!

5more comments