Sto creando un file d.tS per webgl-utils.js da GoogleCome potrei dichiarare un 'scimmia patchata' prototipo nel dattiloscritto
Ho un problema con una delle ultime linee in cui un metodo in un oggetto globale è 'scimmia patch' (credo che questo sia la terminologia destra)
la linea problema si legge:
/**
* Provides requestAnimationFrame in a cross browser way.
*/
window.requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
window.setTimeout(callback, 1000/60);
};
})();
Come dovrei dichiarare il presente nel mio file dattiloscritto in modo da non otterrà errori di compilazione quando uso il funzione:
function tick()
{
requestAnimFrame(tick);
drawScene();
}
ora ho provato:
interface window
{
requestAnimFrame(): any;
}
Ma questo non elimina l'errore:
The name 'requestAnimFrame' does not exist in the current scope
Hai provato a prefissarlo esplicitamente con 'window'? – Bergi
Sì, che dà l'identico errore – Toad
anche, l'intellisense in VisStudio non mostra il metodo. Mostra il normale: requestAnimationFrame() ma non quello nuovo – Toad