from typing import Union


def num_cvt(string: str) -> Union[int, float]:
    """
    >>> num_cvt("2007")
    2007
    >>> num_cvt("3.14")
    3.14
    >>> num_cvt("1,234")
    1234
    """
    try:
        return int(string)
    except ValueError:
        pass
    try:
        return float(string)
    except ValueError:
        pass
    return int(string.replace(",", ""))