我無法弄清楚如何使這個函數不會產生編譯器錯誤。typescript - 類型'數字'的參數不能分配給'string'類型的參數
該函數將在毫秒的持續時間和前置小時/分/秒與0,如果數量少於10
private msToTime(duration:any):string {
var milliseconds:string = String(parseInt((duration%1000)/100))
var seconds:string = String(parseInt((duration/1000)%60))
var minutes:string = String(parseInt((duration/(1000*60))%60))
var hours:string = String(parseInt((duration/(1000*60*60))%24))
hours = (parseInt(hours) < 10) ? "0" + hours : hours;
minutes = (parseInt(minutes) < 10) ? "0" + minutes : minutes;
seconds = (parseInt(seconds) < 10) ? "0" + seconds : seconds;
return hours + ":" + minutes + ":" + seconds;
}