Math function

Hello! which can help me correct the error: The name ‘Math’ could not be found when I use a code to calculate the distance between two points. Thank you.

function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
    var R = 6371; // Radius of the earth in km
    var dLat = (lat2-lat1) * (Math.PI/180);  // deg2rad below
    var dLon = (lon2-lon1) * (Math.PI/180); 
    var a =
        Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos((lat1) * (Math.PI/180)) * Math.cos((lat2) * (Math.PI/180)) * 
        Math.sin(dLon/2) * Math.sin(dLon/2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
        var d = R * c; // Distance in km
        return d;

Please describe the steps needed to reproduce your error. Simply dropping that into a scratch project causes no errors for me (aside from the fact that my tsconfig.json settings are incompatible with the failure to declare types for any of your arguments).