I'm stuck right now trying to port this code to TypeScript.
if (typeof window !== 'undefined') { window.requestAnimFrame = (function(callback){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback){ window.setTimeout(callback, 1000 / 60, new Date().getTime()); }; })(); }
Tsc error:
the parameters provided do not match any signature of the target
I tried declaring an interface WindowEx extends Window containing the signatures, and then switched to (< WindowEx>window).xxx , but I doubt that this is the correct way to convert this "typical" code.
Attempt:
interface WindowEx extends Window { requestAnimFrame(callback, target?):number; webkitRequestAnimationFrame(callback, target?):number; mozRequestAnimationFrame(callback, target?):number; oRequestAnimationFrame(callback, target?):number;
source share