Does anyone know how to cast in TypeScript?
I\'m trying to do this:
var script:HTMLScriptElement = document.getElementsByName(\"script\")[0];
alert(s
Just to clarify, this is correct.
Cannot convert 'NodeList' to 'HTMLScriptElement[]'
as a NodeList
is not an actual array (e.g. it doesn't contain .forEach
, .slice
, .push
, etc...).
Thus if it did convert to HTMLScriptElement[]
in the type system, you'd get no type errors if you tried to call Array.prototype
members on it at compile time, but it would fail at run time.