有人知道如何在TypeScript中进行转换吗?
我正在尝试这样做:
var script:HTMLScriptElement = document.getElementsByName("script")[0];
alert(script.type);
但这给了我一个错误:
Cannot convert 'Node' to 'HTMLScriptElement': Type 'Node' is missing property 'defer' from type 'HTMLScriptElement'
(elementName: string) => NodeList
除非将其强制转换为正确的类型,否则我无法访问script元素的'type'成员,但是我不知道该怎么做。我搜索了文档和样本,但找不到任何东西。