$[-\infty,\infty]$ is equipped with the order topology $\tau$ and (Borel) $\sigma$-algebra $\mathcal B=\sigma(\tau)$.
If $A\subseteq[-\infty,\infty]$ and $i:A\to[-\infty,\infty]$ denotes its inclusion then $A$ is equipped with subspace topology $i^{-1}(\tau)=\{A\cap U\mid U\in\tau\}$.
This subspace topology induces at first hand the $\sigma$-algebra $\mathcal B_A:=\sigma(i^{-1}(\tau))$ but fortunately it can be shown that:$$\mathcal B_A=\sigma(i^{-1}(\tau))=i^{-1}(\sigma(\tau))=i^{-1}(\mathcal B)=\{A\cap B\mid B\in\mathcal B\}$$The second equality is essential here.
Now let $(\Omega,\mathcal A)$ be a measurable space and let $f:\Omega\to[-\infty,\infty]$ be a measurable function - that is $f^{-1}(\mathcal B)\subseteq\mathcal A$ - with $f(\Omega)\subseteq A$.
Then the question rises: is $f$ also measurable if it is regarded as a function $\Omega\to A$?
Fortunately the answer is: "yes".
Observe that $f(\Omega)\subseteq A$ allows us to write $f=ig$ where $g:\Omega\to A$ is prescribed by $\omega\mapsto f(\omega)$.
Then the actual question is now: is function $g:\Omega\to A$ measurable?
Now observe that: $$g^{-1}(\mathcal B_A)=g^{-1}(i^{-1}(\sigma(\tau)))=(ig)^{-1}(\sigma(\tau))=f^{-1}(\sigma(\tau))=f^{-1}(\mathcal B)\subseteq\mathcal A$$which is exactly what we need for measurability of $g$.
If conversely we start with a measurable function $g:\Omega\to A$ then we might wonder whether it is measurable if it is looked at as a function $\Omega\to[-\infty,\infty]$.
That question can be rephrased as: is function $f:=ig:\Omega\to[-\infty,\infty]$ measurable?
Again the answer is "yes".
For this note that $i:A\to[-\infty,\infty]$ is measurable simply because $i^{-1}(\mathcal B)=\mathcal B_A$.
Then $f=ig$ can be recognized as composition of two measurable functions and a composition of measurable functions is measurable.