'Typescript define type for method argument

I have a company object, that looks like this:

{ 
 tracking_hours: {
  open: '8:00',
  close: '20:00'
 }
}

I use it to set values this way:

set({
 openTime: setTime(company, 'open_time'),
 closeTime: setTime(company, 'close_time'),
})

I need somehow set a type for company in setTime function

export function setTime(
    company: {
        tracking_hours: null | any
    },
    type: string,
): number | null {
    if (company.tracking_hours) {
        if (company.tracking_hours[type]) {
            const time = Number(company.tracking_hours[type].split(':')[0])

            if (time) {
                return time
            } else {
                return null
            }
        }

        return null
    }

    return null
}

How can I replace any with its actual type?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source