TypeScript: cast HTMLElement - using function document.getElementsByTagName()

Function document.getElementsByTagName() returns NodeListOf<Element>, Where Element is more generic type extends from type Node. Since TypeScript used lib.d.ts declaration file to recognize native javascript functions and properties, you can find this function's multiple signatures in lib.d.ts with different tag names, each have different return type. For example, document.getElementsByTagName("h1") will return NodeListOf<HTMLHeadingElement>.
Posted by: Muhammad Idrees
On 09 Mar 2016 | Views: 591 | Categories: Visual Studio, Tips & Tricks, Other, ASP.NET

Post your comments


Other lins

.Net Techies
Other lins